Hello everyone, im hoping to get answer here about my task.
Im trying to make a continuous servo to rotate a few degree like 30 or so, and i know that the continuous servo rotate according to the delay. and im trying to control it using a button, when i push it it turn for some degree, and when pushing the button again it turn back to previous degree
i've try one with one condition to rotate to some degree but it only rotates continuously when i press it and stop when im not press it
#include <Servo.h>
const int servoPin = 2; // Servo pin
const int buttonPin = 8; // Pushbutton pin
int buttonState = 0;
int directionState = 0;
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(2);
pinMode(buttonPin, INPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH){
myservo.write(0);
delay(10);
myservo.write(90);
}
}
im currently learning on arduino so my coding probably still a mess. thanks for your time to answer my problem