Code für die Display Ansteuerung

From Hackteria Wiki
Jump to: navigation, search
  1. include <LiquidCrystal.h>

// Initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int switchPin = 6; int switchState = 0; int prevSwitchState = 0; int reply;

void setup() {

 // Initialize the LCD with 16 characters and 2 lines
 lcd.begin(16, 2);
 pinMode(switchPin, INPUT);
 lcd.setCursor(0, 0);
 // Print a message to the first line
 lcd.print("TIC TAC TOE");
 lcd.setCursor(0, 1);
 // Print a message to the second line
 lcd.print("bereit?");
 delay(7000);

}


void loop() {

 // Clear the LCD screen
 //lcd.clear();
 switchState = digitalRead(switchPin);
 if (switchState != prevSwitchState)
 {
   if (switchState == 1)
   {
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print("Du bist dran");
     lcd.setCursor(0,1);
     lcd.print("Spieler 1");
   } 
     else {
     lcd.setCursor(0,0);
     lcd.print("Du bist dran");
     lcd.setCursor(0,1);
    lcd.print("Spieler 2");
     }
 }   
 prevSwitchState = switchState;

}