Um mit einem AVR ein LCD anzusteuern, bedarf es folgenden Dingen:

  • einen AVR (hier Atmega16 mit 16Mhz Quarz) mit 4 freien I/O Ports
  • Ein LCD Display mit Spannungsversorgung.

Am Display muss folgende Beschaltung vorliegen:

'Rs = Portd.0
'RW = ground
'E = Portd.1

'Db4 = Portd.2
'Db5 = Portd.3
'Db6 = Portd.4
'Db7 = Portd.5

Und natürlich die Spannungsversorgung, Kontrasteinstellung des LCD Moduls

Schaltbild:

LCD Beschaltung

Der Bascom Quellcode hierzu sieht folgt aus:

 $regfile = "m16def.dat"
 $crystal = 16000000

 Config Lcdpin = Pin , Db4 = Porta.4 , Db5 = Porta.5 , Db6 = Porta.6 , Db7 = Porta.7 , E = Portb.0 , Rs = Portb.2
   Config Lcd = 16 * 2
     Cls
     Wait 1
   Do
   'Displayposition Zeile 1, Position 1
    Locate 1 , 1
   'Display-Textausgabe
    Lcd "Hallo"
   'Displayposition Zeile 2, Position 1
    Locate 2 , 1
   'Display-Textausgabe
    Lcd "Zeile 2"
    Wait 1
    Loop