lcd-i2c.ino
The 16x2 LCD with I2C module costs the Nano just two pins: SDA and SCL. This sketch initialises the PCF8574 at address 0x27, prints a welcome line then a refreshed analog voltage — the minimal standalone dashboard.
Hardware
An Arduino Nano classic (ATmega328P at 16 MHz, 30-pin DIL breadboard footprint, mini-B USB, 5 V logic, RESET pin at the lower-left corner). Arduino Nano, HD44780 LCD with PCF8574 I2C module (address 0x27 or 0x3F), potentiometer on A0 to test.
Wiring
LCD VCC→5 V, GND→GND, SDA→A4, SCL→A5 (native 328P I2C pins). The module handles R/W and RS internally.
How it works
Wire drives the hardware I2C bus; LiquidCrystal_I2C shapes the HD44780 4-bit commands through the PCF8574. The trailing spaces overwrite leftover digits from previous displays.
Running it
In the Arduino IDE, select the Arduino Nano board and ATmega328P processor, pick the serial port, then upload. The board's 5 V rail suits 5 V sensors; otherwise use 3.3 V on compatible pins.
Variants
Put the backlight on PWM for automatic dimming, or alternate two readings if the screen is small.
lcd-i2c.ino
// LCD 16x2 avec module I2C PCF8574 sur l'Arduino Nano (adresse 0x27).
// Verifier l'adresse avec un scanner I2C si rien ne s'affiche.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Nano ATmega328");
lcd.setCursor(0, 1);
lcd.print("init OK");
Serial.begin(9600);
}
void loop() {
// Mesure analogique affichee sur la ligne du bas
int brut = analogRead(A0);
float tension = brut * (5.0 / 1023.0);
lcd.setCursor(0, 1);
lcd.print("A0:");
lcd.print(tension, 2);
lcd.print("V "); // purge les chiffres residuels
delay(250);
}