Appearance
LCD1602 I2C driver
Module: arduino::driver::output::lcd1602
Driver for HD44780-compatible character LCDs such as 16x2 displays connected through a PCF8574 I2C backpack.
The common backpack wiring is assumed: P0=RS, P1=RW, P2=E, P3=backlight, P4..P7=D4..D7.
Wiring on Arduino Uno
VCC->5VGND->GNDSDA->A4SCL->A5
Basic usage
c3
import arduino::driver::output::lcd1602;
fn void main() @export("start") {
if (!lcd1602::init(0x3F, 16, 2)) {
while (true) {}
}
lcd1602::clear();
lcd1602::set_cursor(0, 0);
lcd1602::print("Hello from C3!");
lcd1602::set_cursor(0, 1);
lcd1602::print("LCD @ 0x3F");
while (true) {}
}API
init(addr, cols, rows) -> boolinitializes the LCD. Use0x3Ffor your display.clear()clears the screen and homes the cursor.home()moves the cursor to the top-left.set_cursor(col, row)sets the cursor position, zero-based.write_char(c)writes one character.print(s)writes a string.backlight(enabled)turns the backlight on or off.display(enabled)turns visible display output on or off without clearing text memory.
See examples/lcd1602-i2c for a complete project.