Ora, questo simpatico chipset mi ha attratto perché può funzionare sia in modalità parallela a 8 bit oppure in modalità seriale SPI, molto utile per ridurre drasticamente il numero di fili per il collegamento.
La libreria che ho trovato nel playground di Arduino mi pare obsoleta, per lo meno non si riesce a compilare con le IDE recenti:
http://playground.arduino.cc/Code/LCD12864
In compenso ho scoperto queste bellissime librerie:
http://code.google.com/p/u8glib/
che supportano molti chipset e molte modalità di comunicazione.
I collegamenti base da fare per entrambe le modalità sono:
Codice: Seleziona tutto
Display - Arduino
1 VSS - GND
2 VDD - +5V
4 RS - A4
5 RW - A2
6 E - A4
17 RST - +5V (RESET NEGATO)
19 BLA - +5V (BackLight Anode)
20 BLK - +5V (BackLight Katode)
Questi sopra sono i PIN che in modalità seriale o parallela non cambiano, ora andiamo a vedere le differenze tra le due configurazione di comunicazione.
Modalità SPI
Codice: Seleziona tutto
Display - Arduino
15 PSB - GND (SELETTORE MODALITA' COMUNICAZIONE)
Codice: Seleziona tutto
Display - Arduino
7..10 DB0..DB3 - 8..11
11..14 DB4..DB7 - 4..7
15 PSB - +5V (SELETTORE MODALITA' COMUNICAZIONE)
Codice: Seleziona tutto
//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17