Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h> //https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Belegung für 16x4 LCD-Modul QC2204A
// mit Sainsmart LCD2004 I2C-Controller
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);
void setup() {
lcd.begin(20,4);
lcd.setCursor(4,1);
lcd.print("Hallo Welt!");
delay(5000);
}
void loop() {
//Display löschen und Cursor nach oben links
lcd.clear();
lcd.home();
//---Zeilen ansprechen
lcd.setCursor(4,0);
lcd.print("Zeile 1");
lcd.setCursor(5,1);
lcd.print("Zeile 2");
lcd.setCursor(6,2);
lcd.print("Zeile 3");
lcd.setCursor(7,3);
lcd.print("Zeile 4");
delay(2000);
//---Display-Inhalt nach rechts scrollen
lcd.scrollDisplayRight();
//lcd.scrollDisplayLeft()
delay(2000);
//---Cursor ein
lcd.clear();
lcd.home();
lcd.print("Cursor blinkt:");
lcd.setCursor(0,1);
lcd.blink();
delay(2000);
//---alternativer Cursor
lcd.clear();
lcd.home();
lcd.print("Cursor Unterstrich:");
lcd.setCursor(0,1);
lcd.cursor();
delay(2000);
//---Zurücksetzen
lcd.clear();
lcd.home();
lcd.noCursor();
lcd.noBlink();
//---Alle Zeichen anzeigen
lcd.print("Alle Zeichen...");
delay (2000);
lcd.clear();
lcd.setCursor(2,0);
int i=1;
for (char c = -128; c < 127; c++,i++){
lcd.print(c);
if (!(i%16)) lcd.setCursor(2,(i/16)%4);
if (!(i%64)) delay(3000);
}
delay(3000);
//---Display aus
lcd.clear();
lcd.home();
lcd.print("Display aus...");
delay(2000);
lcd.off();
delay(2000);
//---Display wieder an
lcd.on();
//lcd.noBacklight();
//lcd.backlight();
}
Das Ergebnis ist eine leicht zu steuernde visuelle Anbindung an den Bediener bei nur 4 Pins belegten Pins. Klasse!
Code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Belegung für 16x4 LCD-Modul QC2204A
// mit Sainsmart LCD2004 I2C-Controller
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3,POSITIVE);
void setup() {
lcd.begin(20,4);
createCustomChars();
lcd.setCursor(2,1);
lcd.print("Eigene Zeichen!");
delay(5000);lcd.clear();
lcd.print("Codes 0x00-0x07");
lcd.setCursor(0, 2);
for (int i=0; i<8; i++)
{
lcd.write(byte(i));
}
}
void loop() {}
void createCustomChars()
{
uint8_t bell[8] = {0x04,0x0E,0x0E,0x0E,0x1F,0x00,0x04,0x00};
uint8_t note[8] = {0x02,0x03,0x02,0x0E,0x1E,0x0C,0x00,0x00};
uint8_t clock[8] = {0x00,0x0E,0x15,0x17,0x11,0x0E,0x00,0x00};
uint8_t heart[8] = {0x00,0x0A,0x1F,0x1F,0x0E,0x04,0x00,0x00};
uint8_t duck[8] = {0x00,0x0C,0x1D,0x0F,0x0F,0x06,0x00,0x00};
uint8_t check[8] = {0x00,0x01,0x03,0x16,0x1C,0x08,0x00,0x00};
uint8_t cross[8] = {0x00,0x1B,0x0E,0x04,0x0E,0x1B,0x00,0x00};
uint8_t retarrow[8] = {0x01,0x01,0x05,0x09,0x1F,0x08,0x04,0x00};
lcd.createChar(0, bell);
lcd.createChar(1, note);
lcd.createChar(2, clock);
lcd.createChar(3, heart);
lcd.createChar(4, duck);
lcd.createChar(5, check);
lcd.createChar(6, cross);
lcd.createChar(7, retarrow);
}
Lesezeichen