Hier ein Sketch zum Display testen für meine Wetterstation:
// 2-wire connection to a HD44780-compatible LCD via shiftregister with:
// Data (and Enable) on Arduino pin 12
// Clock on Arduino pin 13
//
// Shiftregister bits #0 - #1 - not used (bit #0 must be set to zero)
// Shiftregister bit #2 - connects to LCD RS (Register Select)
// Shiftregister bits #3 - #6 on LCD data inputs D4-D7.
// Shiftregister bit #7 - used for enabling the Enable puls.
// LCD R/!W (or rw) hardwired to GND (write to LCD only, no reading from)
//
// USAGE: ShiftRegLCD LCDobjectvariablename(Datapin, Clockpin, Enablepin or TWO_WIRE [, Lines [, Font]]])
// where Lines and Font are optional.
// Enablepin: can be replaced by constant TWO_WIRE, if using only 2 wires.
// Lines: 1 or 2 lines (or more if possible)
// Font : 0 or 1, small or big font (8 or 10 pixel tall font, if available).
#include <ShiftRegLCD.h>
ShiftRegLCD srlcd(8, 9, 7,2,1);
void setup()
{
// Print a message to the LCD.
pinMode(10,OUTPUT);
analogWrite(10,128);
}
void loop()
{
showValues();
delay(5000);
}
void showValues() {
srlcd.setCursor(0, 0);
srlcd.print("IN: ");
srlcd.print(random(19,22));
srlcd.write(223);
srlcd.print("C ");
srlcd.setCursor(10, 0);
srlcd.print("OUT: ");
srlcd.print(random(0,15));
srlcd.write(223);
srlcd.print("C ");
srlcd.setCursor(0, 1);
srlcd.print("IN: ");
srlcd.print(random(60,75));
srlcd.print(" % ");
srlcd.setCursor(10, 1);
srlcd.print("OUT: ");
srlcd.print(random(80,99));
srlcd.print(" % ");
srlcd.setCursor(0, 2);
srlcd.print("LD: ");
srlcd.print(random(980,1040));
srlcd.print(",");
srlcd.print(random(0,99));
srlcd.print(" hPa ");
srlcd.setCursor(0, 3);
srlcd.print("W ");
srlcd.print(random(10,25));
srlcd.print(",");
srlcd.print(random(0,9));
srlcd.print("km/h ");
srlcd.setCursor(12, 3);
srlcd.print("R ");
srlcd.print(random(10,25));
srlcd.print(" mm ");
}
Angeschlossen nach folgendem Schema:
Display ist ein 4x20.