Writing a code that will look at sensor1 and sensor2 and then drive a servo motor either one direction or the reverse. The code is not finished but I check it at each stage to ensure that it is error free before continuing. I have two "IF" statements; the first one looks to see if sensor1 is HIGH and sensor2 is LOW then the servo motor turns one direction. The second "IF" statement, in my mind, should be identical, syntax wise, to the the first, just the sensors and the direction of the servo motor is reversed. I get the error "expected ')' before numeric constant". For the life of me I have stared at this until I've gotten cross-eyed and cannot see where I have gone wrong. Below is the sketch. And thank you for your help.
PS-I have tried to highlight the error but could not preview with the highlights. In case it doesn't get highlighted in lime green the error is "for(int pos = 180; pos >=1; pos--1);" 6 lines from the bottom.
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
int sensor1=2;
int sensor2=3;
int sensorState1=0;
int sensorState2=0;
int lastsensorState1=0;
int lastsensorState2=0;
#include <Servo.h>
Servo servo1; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
pinMode (sensor1, INPUT);
pinMode (sensor2, INPUT);
servo1.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop(){
//Read the state of the sensor buttons;
sensorState1=digitalRead(sensor1);
sensorState2-digitalRead(sensor2);
//check if the sensor1 is positive
//If it is, the sensorState is HIGH;
if(sensorState1==HIGH);
(sensorState2==LOW); {
for(pos = 0; pos < 180; pos += 1); // goes from 0 degrees to 180 degrees in steps of 1 degree
for(int pos=0; pos<180; pos++);
servo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
if(sensorState2==HIGH);
(sensorState1==LOW);{
for(pos = 180; pos>=1; pos-=1); // goes from 180 degrees to 0 degrees
[color=limegreen] for(int pos = 180; pos >=1; pos--1);[/color]
servo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); ) // waits 15ms for the servo to reach the position
}
//for next time through the loop
{(lastsensorState1=sensorState1);
(lastsensorState2=sensorState2);}}
[\code]
Thank you again for your help.