Da ich mich schon immer mal mit Mikrocontrollern beschäftigen wollte, habe ich mir vor ein paar Tagen den Arduino Duemilanove geholt und versuche mich jetzt an einem LCD mit 4x20 Zeichen
Ich hab es so angeschlossen wie im Tutorial:
nur nicht die pins D0 - D3 sondern D4 - D7 wie es wohl auch gehört...
Es wird auch etwas angezeigt, nur wenn ich viele Zeichen schreibe wiederholen sie sich in der 2. Zeile und wenn ich bspw.
lcd.setCursor(0,1);
lcd.print("hallo");
programmiere, wird "hallo" in der 3. Zeile ausgegeben.
Ist wohl klar dass hier was mit der Adressierung nicht stimmt. Ich hab schon versucht in der LiquidCrystal.cpp die Zeile
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
in int row_offsets[] = { 0x00, 0x20, 0x40, 0x60 }; zu ändern, aber das hat irgendwie keine Auswirkung. Wäre super wenn mir da wer bei helfen könnte.
Was ich auch nicht verstehe ist, dass im Tutorial unten bei dem Codebeispiel so Sachen stehen wie
lcd.begin(2,16);
er kennt bei mir die Funktion begin() gar nicht...
also wenn Du die LiquidCrystal Library verwendest, dann könnte Dein Problem sein, dass beim initialisieren der Klasse das Display wie folgt eingerichtet wird:
Damit wird es aber als ein-/zweizeiliges Display initialisiert und nicht als vierzeiliges Display.
An Hand des PDFs müsstest Du mal ausrechnen, was Du statt 0x28 als initialisierung an das LCD schicken musst (ich habe da was bzgl. 0x09 - 4 Zeilen Modus gefunden, aber wie man das verwendet müsstest Du selbst ausprobieren)
Hab's hinbekommen. Das Problem war, dass man bei dem LCD-Controller KS0073 erst mit Function Set das RE-Bit setzen muss, dann dann ist das extended Function Set aktiviert und darin kann man dann auf 4-Line Display umschalten.
Hab dazu folgende Befehle verwendet. Vielleicht brauchts ja nochmal einer
command(0x2C); //Function set RE on
delayMicroseconds(150);
command(0x09); //ext. Function set 4-line display
delayMicroseconds(150);
command(0x28); //Function set RE off
habe mir bei Reichelt auch so ein Display gekauft. Nun suche ich eine Adapterplatine, damit ich das LCD auf ein RM 2.54 Experimentierboard stecken kann.
Wie hast Du die Anschlüsse an den Arduino gemacht?
82d83
< begin(16, 1);
108,122c109,111
< //put the LCD into 4 bit or 8 bit mode
< if (! (_displayfunction & LCD_8BITMODE)) {
< // this is according to the hitachi HD44780 datasheet
< // figure 24, pg 46
<
< // we start in 8bit mode, try to set 4 bit mode
< write4bits(0x03);
< delayMicroseconds(4500); // wait min 4.1ms
<
< // second try
< write4bits(0x03);
< delayMicroseconds(4500); // wait min 4.1ms
<
< // third go!
< write4bits(0x03);
// hack for 20x4 Display
if (cols==20 && lines==4) {
command(0x2C); //Function set RE on
124,136c113
<
< // finally, set to 8-bit interface
< write4bits(0x02);
< } else {
< // this is according to the hitachi HD44780 datasheet
< // page 45 figure 23
<
< // Send function set command sequence
< command(LCD_FUNCTIONSET | _displayfunction);
< delayMicroseconds(4500); // wait more than 4.1ms
<
< // second try
< command(LCD_FUNCTIONSET | _displayfunction);
command(0x09); //ext. Function set 4-line display
138,140c115,153
<
< // third go
< command(LCD_FUNCTIONSET | _displayfunction);
command(0x28); //Function set RE off
_20x4hack=1;
}
//put the LCD into 4 bit or 8 bit mode
else
{
if (! (_displayfunction & LCD_8BITMODE)) {
// this is according to the hitachi HD44780 datasheet
// figure 24, pg 46
// we start in 8bit mode, try to set 4 bit mode
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms
// second try
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms
// third go!
write4bits(0x03);
delayMicroseconds(150);
// finally, set to 8-bit interface
write4bits(0x02);
} else {
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(4500); // wait more than 4.1ms
// second try
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(150);
// third go
command(LCD_FUNCTIONSET | _displayfunction);
}
175c188,200
< int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };