Programming the Ultrasonic sensor


#46

Sorry I am afraid there is no way to code and let it running in distance not time for mBot motors.


#47

So the only is to make the robot move for a period of time and check the distance covered and start to adjust time according to the distance i want?
Another question is how can i get a return value for the distance measured by the ultrasonic sensor.
I created 2 variables and set each variable to a distance measured by the ultrasonic … then i set it in motion to move the difference between these two values and it’s not working no matter what i do … any ideas to make it work??
Thanks in advance


#48

For better follow up, I created a ticket and please check your email box.


#49

Thank you it works, I been looking for a solution so that I can use a generic HC-SR04. I just solder Echo and Trig and connect to ME JR25. then use the mblock code. It works perfectly. I hope I can also contribute on this forum. Thanks again


#50

My Ultrasonic sensor is not working. However, it is connected on port 3. Any suggestions? .


#51

Hi dhanushx012,

Please chang the RJ25 cable between ultrasonic sensor and the mainboard have a try. You can use the cable for the line follower senser temporarily.

Then please reset factory firmware for mBot with mBlock 5 software and see if the obstacle avoidance mode works.