So I am writing code to control a servo with an RC radio. I am using an Arduino Mega. I get this error whenever I compile. I am not that experienced with Arduino so I am probably not doing something right. Thanks for the help!
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Users\ethan\Desktop\Periferals_control\Periferals_control.ino: In function 'void loop()':
Periferals_control:46: error: expected ';' before '{' token
{
^
exit status 1 expected ';' before '{' token
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
#include <Servo.h>
Servo servo1;
Servo servo2;
//the following are all ~PWM capable ports
int servoElevator_PwmIn = 6; //Elevator Servo
int servoGrabber_PwmIn = 7; //Grabber Servo
//Channels on AT9
int leftStickVertical = 2; //Channel 3
int rightStickVertical = 3; //Channel 7
int elevatorServoStop = 50;
void setup() {
//pinMode(servoGrabber_PwmIn, OUTPUT);
//pinMode(servoElevator_PwmIn, OUTPUT);
pinMode(leftStickVertical, INPUT);
pinMode(rightStickVertical, INPUT);
Serial.begin(9600);
servo1.attach(6);
servo2.attach(servoGrabber_PwmIn);
}
void loop() {
int leftStickVerticalPwm = pulseIn(leftStickVertical, HIGH, 25000);
int rightStickVerticalPwm = pulseIn(rightStickVertical, HIGH, 25000);
Serial.print(leftStickVerticalPwm);
Serial.print("\t");
Serial.print(rightStickVerticalPwm);
Serial.print("\n");
if (rightStickVerticalPwm == 0)
{
servo1.write(elevatorServoStop);
}
else if (rightStickVerticalPwm > 1500)
{
servo1.write(100);
}
else (rightStickVerticalPwm < 1400)
{
servo1.write(30);
}
}