I'm having a problem with the if then else. I need to make it so that when two inputs at the same time read then start a motor. I am getting an error exit status 1 'else' without a previous 'if'. Any help or suggestions are greatly appreciated. My code follows.
int buttonpin = 0; //Sets pin 0 to be called buttonpin.
int leftmotor = 10; //Sets pin 10 to control Left Motors.
int rightmotor = 11; //Sets ping 11 to control Right Motor
int leftline = 5; //Left line follower input.
int middleline = 4; //Middle line follower input.
int rightline = 3; //Right line follower input.
int bumper = 7; //Bumber swithch input
//add pins for for ping pong ball device.
void setup() {
pinMode(buttonpin, INPUT); //sets pin 0 as input.
pinMode(leftmotor, OUTPUT); //sets pin 10 as output.
pinMode(rightmotor, OUTPUT); //Sets pin 11 as output.
pinMode(leftline, INPUT); //Sets pin 5 as input.
pinMode(middleline, INPUT); //Sets pin 4 as input.
pinMode(rightline, INPUT); //Sets pin 3 as input.
pinMode(bumper, INPUT); //Sets pin 7 as input.
// configure pins yet to be added listed above.
}
void loop() {
// Main runtime instruction set.
// Read sensor input.
if (digitalRead(leftline == HIGH));{
(digitalRead(rightline == HIGH));
{
digitalWrite,(rightmotor,HIGH);
digitalWrite,(leftmotor,HIGH);
else
{
// Do nothing.
}
void loop() {
// Main runtime instruction set.
// Read sensor input.
if (digitalRead(middleline == HIGH));{
(digitalRead(rightline == HIGH));
{
digitalWrite,(rightmotor,LOW);
digitalWrite,(leftmotor,HIGH);
else
{
// Do nothing.
}
void loop() {
// Main runtime instruction set.
// Read sensor input.
if (digitalRead(leftline == HIGH));{
(digitalRead(middleline == HIGH));
{
digitalWrite,(rightmotor,HIGH);
digitalWrite,(leftmotor,LOW);
else
{
// Do nothing.
}
void loop() {
// Main runtime instruction set.
// Read sensor input.
if (digitalRead(leftline == HIGH));{
(digitalRead(rightline == HIGH));
{
digitalWrite,(rightmotor,HIGH);
digitalWrite,(leftmotor,HIGH);
else
{
// Do nothing.
}
}
}