Hello all, I just received a kit in the mail and I started to tinker with it.
My end goal was to to make the servo rotate and the LED light up when the button was pushed. Then on release, the servo will reset to where it started.
From the code I have here, I assumed that would work, but it does not. When loaded the servo spins full rotations.
void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
myservo.write(180);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
myservo.write(90);
}
}
Now from what little I know about servos, servos should not even rotate a full circle.
The servo I am using is a super cheap, if I break it, it's okay TowerPro SG90 9G Mini Servo. All the information I can find on this servo is that you need to "hack" it to make it spin full rotations, so I am confused.
This all may be irrelevant because I have a Futaba at home that I will try next, but I didn't want to break it testing code. XD
Sorry for what is probably such a basic answer. I did search, and all the answers pointed to the servo being a full rotation "servo", but this is apparently not the case with this one? Maybe..
Thanks!