Stap 6: Het toevoegen van LCD in het Project
Nu voeg ik lcd in het project om te zien de status van magneetventiel
[code]#include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); int timer = 1000; int solid[] = { A0, A1, A2, A3 }; int pinCount = 4; int sw[]={6}; void setup() { lcd.begin(16, 2); for (int thisPin = 0; thisPin < pinCount; thisPin++) { pinMode(solid[thisPin], OUTPUT); } pinMode(sw[0], INPUT); digitalWrite(sw[0], HIGH); }void loop() { lcd.setCursor(0, 0); lcd.print("M1 OFF"); lcd.setCursor(8, 0); lcd.print("M2 OFF"); lcd.setCursor(0, 1); lcd.print("M3 OFF"); lcd.setCursor(8, 1); lcd.print("M4 OFF"); if(digitalRead(sw[0]) == LOW) { lcd.setCursor(0, 0); lcd.print("M1 ON"); digitalWrite(solid[0], HIGH); delay(timer); digitalWrite(solid[0], LOW); lcd.setCursor(0, 0); lcd.print("M1 OFF"); lcd.setCursor(8, 0); lcd.print("M2 ON"); digitalWrite(solid[1], HIGH); delay(timer); digitalWrite(solid[1], LOW); lcd.setCursor(8, 0); lcd.print("M2 OFF"); lcd.setCursor(0, 1); lcd.print("M3 ON"); digitalWrite(solid[2], HIGH); delay(timer); digitalWrite(solid[2], LOW); lcd.setCursor(0, 1); lcd.print("M3 OFF"); lcd.setCursor(8, 1); lcd.print("M4 ON"); digitalWrite(solid[3], HIGH); delay(timer); digitalWrite(solid[3], LOW); lcd.setCursor(8, 1); lcd.print("M4 OFF"); } }
[/code]