how to program HC SR04 ultrasonic sensor

Hi, can anyone guide me on how to obtain distance from sonar sensor using processing IDE for raspberry pi

The first thing to do is a search in the forum: https://discourse.processing.org/search?q=ultrasonic

You will get a lead from previous posts. You can try to use it for your goals. If you get stuck, you can provide some code showing your approach and telling us what part you thing is not working. Also, when it comes to arduino, advise is limited as it is very likely nobody will have a setup like yours, which makes it hard to help in the first place. You can help by providing proper details about your issue.

Kf