Pilotare un display LCD (driver HD44780) con Arduino Nano

Chi non ha un display LCD 16x2 con driver Hitachi HD44780 nel cassetto della scrivania?

Chi non ha un display LCD 16x2 con driver Hitachi HD44780 nel cassetto della scrivania?

E' lì. Fermo. Spento. Ti sta guardando.

Accanto a lui un Arduino Nano.

Entrambi sanno che vorresti scoprire come visualizzare cose inutili sul display!

Simulazione su Tinkercad!

 


 

Il display LCD 16x2 con driver Hitachi HD44780

Il display che ho utilizzato può mostrare 16 caratteri su due linee ed è retroilluminato.

Possiede infatti 16 contatti; il tipo non retroilluminato ne ha 14.

La piedinatura è la seguente:

1 VSS GND - Negativo alimentazione
2 VCC Positivo alimentazione (+5V)
3 Vee Contrasto
4 RS selezione del registro
5 R/W 1 per Lettura - 0 per Scrittura 
6 Enable (E) Abilitazione scrittura
7 DB0 linea dati 0
8 DB1 linea dati 1
9 DB2 linea dati 2
10 DB3 linea dati 3
11 DB4 linea dati 4
12 DB5 linea dati 5
13 DB6 linea dati 6
14 DB7 linea dati 7
15 Led+ positivo retroilluminazione
16 Led- negativo retroilluminazione

 

Collegamento con Arduino Nano

I collegamenti tra Arduino Nano e il display lcd sono i seguenti:

Breadboard and display

Schema elettrico Arduino-Display LCD:

Schema elettrico

Codice

L'importazione della libreria "LiquidCrystal" è possibile dal menu "Stretck"-> "#include libreria" -> LiquidCrystal.

Il codice da caricare nell' Arduino Nano è il seguente:

#include <LiquidCrystal.h>


LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() 
{
  Serial.begin(9600);

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);

  lcd.cursor() ;
  // Print a message to the LCD
  lcd.print("hello, world!");

  delay(1000);
  lcd.clear();

  // (note: line 1 is the second row, since counting begins with 0):
  // set the cursor to column 0, line 0
  lcd.setCursor(0, 0);
  lcd.print("Visit");
  

  lcd.setCursor(0, 1);
  lcd.print("iemma.it");

  delay(1000);

}

void loop() {

// scroll 13 positions (string length) to the left
  // to move it offscreen left:
  for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft();
    // wait a bit:
    delay(150);
  }

  // scroll 29 positions (string length + display length) to the right
  // to move it offscreen right:
  for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
    // scroll one position right:
    lcd.scrollDisplayRight();
    // wait a bit:
    delay(150);
  }

  // scroll 16 positions (display length + string length) to the left
  // to move it back to center:
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft();
    // wait a bit:
    delay(150);
  }

  // delay at the end of the full loop:
  delay(1000);

}

Buon divertimento!

Se hai voglia di lasciarmi un commento mi trovi su Linkedin.