I'm trying to control a servo on my nano with a push button. (move to 0 at initial, move to 180 on a button push, reset to 0 after another button push).
The code I have for the above was doing nothing so I moved on to troubleshooting the servo itself.
I found that this code will move the servo back and forth as it should
#include <Servo.h>
Servo servo;
void setup() {
servo.attach(5);
}
void loop() {
for(int i=0;i<180; i++){
servo.write(i);
delay(15);
}
for(int i=180; i>0; i--){
servo.write(i);
delay(7);
}
}
However, this code does nothing.
#include <Servo.h>
Servo servo;
void setup() {
servo.attach(5);
}
void loop() {
servo.write(0);
delay(400);
servo.write(180);
delay(400);
}
No changes in setup between the code change, just the code itself.
The servo I'm using is http://www.agfrc.com/index.php?id=1894
I'm powering the unit with a 5v 2a power supply usually meant for charging phones.
Both code sets work properly in driving an SG90 with no issues.
I'm hoping in figuring this out I can then figure out why my code with button presses does not work.
Thanks.