Vous êtes sur la page 1sur 1

#define CW 7 //CW is defined as pin #7//

#define CCW 8 //CCW is defined as pin #8//


const int switchPin1 = 2;
const int switchPin2 = 3;
const int switchPin3 = 4;
const int switchPin4 = 5;
int reading;
int zzzz;
int qq;
int rr;
const int former = HIGH;
int previous ;
void setup()
{ //Setup runs once//
pinMode(switchPin1, INPUT);
pinMode(switchPin2, INPUT);
pinMode(switchPin3, INPUT);
pinMode(switchPin4, INPUT);
pinMode(CW, OUTPUT); //Set CW as an output//
pinMode(CCW, OUTPUT); //Set CCW as an output//

}
void loop()
{ //Loop runs forever//
reading = digitalRead(switchPin1);
if (reading == HIGH )
{
delay(7000);
digitalWrite(CCW,HIGH); //Motor runs clockwise//
delay(2100);//for 1 second//
digitalWrite(CCW, LOW);
}

zzzz = digitalRead(switchPin2);
if (zzzz == HIGH ){
delay(7000);
digitalWrite(CW,HIGH); //Motor runs clockwise//
delay(2100); //for 1 second//
digitalWrite(CW, LOW); }//Motor stops//}
qq = digitalRead(switchPin3);
if (qq == HIGH ){
delay(7000);
digitalWrite(CCW,HIGH); //Motor runs clockwise//
delay(2100); //for 1 second//
digitalWrite(CCW, LOW); }//Motor stops//}
rr = digitalRead(switchPin4);
if (rr == HIGH ){
delay(7000);
digitalWrite(CW,HIGH); //Motor runs clockwise//
delay(2100); //for 1 second//
digitalWrite(CW, LOW); }//Motor stops//}
}

Vous aimerez peut-être aussi