My Programming inst working and its giving me HELL, I have 4 Servo's and 4 Push buttons, however the programming just isn't compiling, it says error: else without a previous if, for all my else's.
#include <Servo.h> // servo library
const int clawBut = 2; // pushbutton 1 pin
const int leftBut = 2; // pushbutton 1 pin
const int rightBut = 2; // pushbutton 1 pin
const int swivelBut = 2; // pushbutton 1 pin
Servo claw;
Servo left;
Servo right;
Servo swivel;
void setup()
{
pinMode(clawBut, INPUT);
pinMode (leftBut, INPUT);
pinMode (rightBut, INPUT);
pinMode(swivelBut, INPUT);
claw.attach(9);
swivel.attach(10);
right.attach(11);
left.attach(12);
}
void loop()
{
int clawval;
int leftval;
int rightval;
int swivelval;
int position;
clawval = digitalRead(clawBut);
leftval = digitalRead(leftBut);
rightval = digitalRead(rightBut);
leftval = digitalRead(leftBut);
if (clawval == LOW);
{
claw.write(90); // move servo
}
else{
claw.write(0);
}
if (leftval == LOW);
{
left.write(90); // move servo
}
else{
left.write(0);
}
if (rightval == LOW);
{
right.write(90); // move servo
}
else{
right.write(0);
}
if (swivelval == LOW);
{
swivel.write(90); // move servo
}
else{
swivel.write(0);
}
}
sketch_oct27a.ino (1.1 KB)