18. November 2010
Mit Hilfe der LCD Anzeige erforschten wir den Gebrauch einer asynchronen, seriellen Schnittstelle.#include #define txPin 12 SoftwareSerial LCD = SoftwareSerial(0, txPin); // since the LCD does not send data back to the Arduino, we should only define the txPin void setup(){ pinMode(txPin, OUTPUT); LCD.begin(9600); Serial.begin(9600); } void loop(){ clearLCD(); //Rouven(); Stefan(); /* for(int i = 0; i <= 32; i++){ clearLCD(); goTo(i); LCD.print(1, BYTE); delay(150); }*/ } void asciiScroller(){ clearLCD(); for(int i = 1; i < 128; i++){ LCD.print(i, BYTE); delay(200); Serial.println(i); } } void srollingLetter(){ clearLCD(); for(int i = 0; i <= 32; i++){ clearLCD(); goTo(i); LCD.print(1, BYTE); delay(300); } } void Rouven(){ clearLCD(); selectLineOne(); LCD.print("Rouven"); selectLineTwo(); LCD.print("Buehlmann"); delay(500); } void Stefan(){ clearLCD(); selectLineOne(); LCD.print("Stefan"); selectLineTwo(); LCD.print("Wanner"); delay(500); } void clearLCD(){ LCD.print(0xFE, BYTE); //command flag LCD.print(0x01, BYTE); //clear command. } void selectLineOne(){ //puts the cursor at line 0 char 0. LCD.print(0xFE, BYTE); //command flag LCD.print(128, BYTE); //position } void selectLineTwo(){ //puts the cursor at line 2 char 0. LCD.print(0xFE, BYTE); //command flag LCD.print(192, BYTE); //position } void toTheRight(){ LCD.print(0xFE, BYTE); LCD.print(0x14, BYTE); } void goTo(int position) { //position = line 1: 0-19, line 2: 20-39, etc, 79+ defaults back to 0 if (position<17){ LCD.print(0xFE, BYTE); //command flag LCD.print((position+128), BYTE); //position }else if (position<33){LCD.print(0xFE, BYTE); //command flag LCD.print((position+128+64-17), BYTE); //position } else { goTo(0); } } <pre>