Electronics > Electronics

arduino with HC SR 04


hi.. i bought an HC SR 04 and arduino.
I found this link to connect the HC_SR04 module to the arduino uno (http://www.essentialtech.co.nz/content/first_play_arduino_uno_and_hcsr04_ultrasonic_distance_module)

Well i want my robot to stop its motion when an obstacle is detected.. the code in the above link is useful to measure the distance.. but could someone help me in modifying it to stop the motion of the robot below a certain distance like say 20 cm away from the obstacle?? thank you in  advance..

in the loop() method:

--- Code: ---if (distance <= 20)

--- End code ---

The Stop() method would cut the power to the motors (or whatever you're using)...


[0] Message Index

Go to full version