robot chodzący unikający przeszkód

Hi
I have a problem because I can not create a sequence that will stop the servos at the moment when the hc-sr04 sensor detects an obstacle …

czasem trzeba sprezyc poprostu swoj mozg! :nerd_face:
Sometimes you just have to start your brain!

grafik

Using the if-else like that, you are going to have servo moving to 1 (true) or 0 (false) position without stopping in between.

If you want to move to position of sine-wave output, then stop at current location when a sensor detects obstacle, then you want servo-ACT to be true until sensor detects obstacle, then change servo-ACT to false so it ignores input value. The down-side is that servo will turn off, so if there is pressure on it, it will free-wheel to wherever is pushed.

Probably a better solution is to only update sine-wave when sensor is not detecting obstacle. Do this by connecting to sine-wave-EN and only setting it true when there is no obstacle.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.