For my robot I'm using a couple of servos I modded to spin continuously without stopping to drive the wheels. I'm also using an ultrasonic sensor to detect walls. When a wall is detected the only way I found to stop the servo was to just detach it. Then the robot is supposed to roll backwards for 1 second, then spin only the left wheel to turn, then turn both wheels again until another wall is detected.
The problem I'm having is once I detach the servo, I'm not sure what I need to write to reattach it. Do you know what function I need to write for this? I've tried using the attach function with no luck so far.
AWOL:
Why not just set the "angle" to 90 (or whatever pulse width corresponds to "stop")?
I was trying that but it didn't work.
UKHeliBob:
Why do you want to do this ? Is it because you can't write a value to the servo that makes it stop ?
Yes, in the code when I wrote servo1.write(180);
Then wrote servo1.write(0); the servo would just keep spinning the same direction.
I figured out the problem. When you mod the servo like I did, you mess with the knob that's right under where you attach an arm to a servo. When you mod it, you drill a hole through that part and chisel out the middle of the knob so you can turn it with a screwdriver. I had that knob turned to the wrong position I guess. So, anyone reading this if you have the same problem with a servo you modded, try messing with that knob.
Anyone who doesn't know what the hell I'm talking about (I had trouble explaining it) watch this.