I'm making a project that includes a continuous rotation servo that will need to go left with one button, right with another, and the disabled and enabled (a toggle) with another button. Here is how far I've gotten, and please keep it simple. This is my first class with Arduino. Thanks for any helpful support.
MY CURRENT SKETCH (I NEED TO DISABLE AND ENABLE THE SERVO NOW): #include <Servo.h> // add servo library #define sw1_pin 5 #define sw2_pin 6
Servo myservo; // create servo object to control a servo
You can detach() a servo and attach() it again when required or you could use a variable to keep track of its status and ignore commands to it when it is disabled.
You can detach() a servo and attach() it again when required or you could use a variable to keep track of its status and ignore commands to it when it is disabled.
UKHeliBob:
What do you mean by enable/disable ?
You can detach() a servo and attach() it again when required or you could use a variable to keep track of its status and ignore commands to it when it is disabled.
When I say disable/enable I mean I want to turn off the servo instead of keeping it at 90 so it won't move and it won't burn out b/c of staying on. I'll do research on your command, thanks.
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Before you post your code, in the IDE select TOOLS, AUTO FORMAT, this will indent your code so it will be easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Kite1433:
I'm making a project that includes a continuous rotation servo that will need to go left with one button, right with another, and the disabled and enabled (a toggle) with another button.
I think that means that the 3rd button is used to disable the other two buttons rather than to disable the servo.
If that is the case create a variable called (say) servoEnabled and change it between true and false using the 3rd button.
Then the code for buttons 1 and 2 will check servoEnabled and if it is false they will do nothing