Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

LCD DISPLAY [Serielle Schnittstelle]

18. November 2010

Mit Hilfe der LCD Anzeige erforschten wir den Gebrauch einer asynchronen, seriellen Schnittstelle.

Mein Name auf zwei Zeilen

#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>