Hi every one
I have a project for packaging and I use servo as a final gate
but every day this servo forget its angel and I have to edit the angel daily
could you help me to save home angel of servo and fix this problem
you will find my Arduino code and I will paste link on youtube for servo gate
thank you so much
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(12, INPUT_PULLUP);
pinMode(13, OUTPUT);
myservo.attach(9); // attaches the servo on pin 9 to the servo object
TIMSK0=0;
}
void loop() {
//read the pushbutton value into a variable
int sensorVal = digitalRead(12);
//print out the value of the pushbutton
// Keep in mind the pullup means the pushbutton's
// logic is inverted. It goes HIGH when it's open,
// and LOW when it's pressed. Turn on pin 13 when the
// button's pressed, and off when it's not:
if (sensorVal == HIGH) {
myservo.write(180);
digitalWrite(13, LOW);
} else {
myservo.write(90);
digitalWrite(13, HIGH);
}
}