1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int switchPin = 1;
const int motorPin = 9;
int switchState = 0;
int reply;
void setup(){
lcd.begin(16, 2);
pinMode(switchPin, INPUT);
lcd.print("m");
lcd.setCursor(0, 1);
lcd.print("S");
pinMode(motorPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void loop(){
switchState = digitalRead(switchPin);
if (switchState == HIGH) {
digitalWrite(motorPin, HIGH);
if (switchState == HIGH){
lcd.setCursor(0, 0);
lcd.print("Moteur Tourne");
lcd.setCursor(0, 1);
lcd.print("Marche AVANT");
}
}
else {
digitalWrite(motorPin, LOW);
lcd.setCursor(0, 0);
lcd.print("Moteur Arret");
lcd.setCursor(0, 1);
lcd.print("STOP");
}
} |
Partager