Robin2:
I don't see button A or D or B in that code so how am I supposed to know how to help?Post a link to the datasheet for your keyfob and receiver.
And please modify your post and use the code button </>
so your code looks like this
and is easy to copy to a text editor. See How to use the Forum
...R
#include <Servo.h>
int A = 8; // button A input
int D = 7; // button D input
int B = 4; // button B input
int servoPin = 9;
int angle = 90;
int change = 15; // this value determines how much the angle changes each time through the loop
Servo myservo;
void setup(){
pinMode(A, INPUT); // initialize pins
pinMode(D, INPUT);
pinMode(B, INPUT);
digitalWrite(A, HIGH); // set internal pull up resistors
digitalWrite(D, HIGH);
digitalWrite(B, HIGH);
myservo.attach(servoPin);
}
void loop(){
if( digitalRead(A) == LOW) {
// here if increment switch pressed
angle = angle + change;
}
if( digitalRead(D) == LOW) {
// here if decrement switch pressed
angle = angle - change;
}
if( digitalRead(B) == LOW) {
// here if decrement switch pressed
angle = angle + change;
}
angle = constrain(angle, 0, 180); // limit value of angle
myservo.write(angle);
delay(20);
}
I do not have access to the keyfob and receiver datasheet. I can't seem to get my input button B to work. It works fine with A and D button inputs. Also, how can I make the angles precise and stop the servo motor from locking up so I don't have to keep resetting it?