🛠 Afficher sur un LCD 16×2 en bus parallèle 8 bits

Arduino Mega 2560 (Rev3) · intermediaire · Schéma : IMG-mega-2560-intermediaire-3-lcd-16x2.svg — écran LCD 16×2 à contrôleur HD44780 câblé en bus 8 bits sur les broches 22 à 32 de l’Arduino Mega 2560, potentiomètre de contraste sur V0

Objectives

Take advantage of the 54 I/O pins on the Mega 2560 to wire up a 16×2 HD44780 character display in full 8-bit mode (eight data lines D0–D7 plus RS, E, and RW, totaling eleven pins) — a luxury that is impossible on an Uno without sacrificing half of its pins. The 8-bit bus doubles the write speed compared to the classic 4-bit mode.

Hardware

Wiring used (free pins on the Mega): RS=22, RW=23 (tied to GND for write-only operation), E=24, D0–D7 = 25 to 32. LCD: VSS→GND, VDD→5 V, V0→potentiometer wiper (the other two legs: 5 V and GND). The display is designed for 5 V logic, the nominal voltage of the Mega's pins.

Complete Code

// LCD 16x2 en bus 8 bits — bibliothèque LiquidCrystal
#include <LiquidCrystal.h>

// (RS, RW, E, D0, D1, D2, D3, D4, D5, D6, D7) : mode 8 bits
LiquidCrystal lcd(22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32);

void setup {
  lcd.begin(16, 2);
  lcd.print(F("Mega 2560"));
  lcd.setCursor(0, 1);
  lcd.print(F("Bus 8 bits"));
}

void loop {
  lcd.setCursor(11, 0);
  lcd.print(millis / 1000);   // chrono sur la 1re ligne
}

Expected Verification

"Mega 2560" and "8-bit Bus" are displayed on the two lines, with a seconds counter updating at the end of the first line. By adjusting the potentiometer, the contrast varies from completely off to completely black.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials