I need help writing this program to control a servo motor with three pushbuttons. One to turn it left another to right and the middle one to reset it’s position to 90 degrees but i keep getting the error message saying expected initializer before viod. Thanks in advance.
#include <Servo.h>
Servo myservo;
int pushButton1 = 13; // right turn
int pushButton2 = 12; //at 90
int pushButton3 = 11; //left turn
int val
void setup() {
Serial.begin(9600);
myservo.attach(8); // servo is attached to pin 8
myservo.write(90);
pinMode(pushButton1, INPUT);
pinMode(pushButton2, INPUT);
pinMode(pushButton3, INPUT);
}
void loop() {
if(digitalRead(pushButton1) == HIGH)
{
val = val + 1;
Serial.println(“right”);
}
if( digitalRead(pushButton2) == HIGH)
{
val = 90;
Serial.println(“middle”);
}
if (digitalRead(pushButton2) == HIGH)
val = val - 1;
Serial.println(“left”);
}
my.servo.write(val);
delay(20)
}