Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: GPSDevice TestTextLCD SD to Flash Data Transfer DrumMachine ... more
Fork of TextLCD by
You are viewing an older revision! See the latest version
Homepage
Example¶
Hello World! for the TextLCD
#include "mbed.h"
#include "TextLCD.h"
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
// I2C Communication
I2C i2c_lcd(p28,p27); // SDA, SCL
// SPI Communication
SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2); // rs, e, d4-d7
TextLCD lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type
//TextLCD lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 addr, LCD Type, Ctrl Type
//TextLCD lcd(&spi_lcd, p8, TextLCD::LCD24x4); // SPI bus, CS pin, LCD Type
int main() {
pc.printf("LCD Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());
for (int row=0; row<lcd.rows(); row++) {
int col=0;
pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
// lcd.putc('-');
lcd.putc('0' + row);
for (col=1; col<lcd.columns()-1; col++) {
lcd.putc('*');
}
pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
lcd.putc('+');
}
// Show cursor as blinking character
lcd.setCursor(TextLCD::CurOff_BlkOn);
// Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780.
// They are defined by a 5x7 bitpattern.
lcd.setUDC(0, (char *) udc_0); // Show |>
lcd.putc(0);
lcd.setUDC(1, (char *) udc_1); // Show <|
lcd.putc(1);
}
