Shop OBEX P1 Docs P2 Docs Learn Events
I2C LCD Code for P1 — Parallax Forums

I2C LCD Code for P1

JonnyMacJonnyMac Posts: 9,104
edited 2022-01-26 18:14 in PASM/Spin (P1)

Per an email request I'm uploading an updated version of my P1 I2C LCD code. This is where it started, was improved for the P2, and now those improvements have been back-ported to the P1. I've also included the P1 version of my generic I2C scanner for investigating devices on your selected I2C pins (usually P28 and P29 on the P1).

Comments

  • Jon,
    On behalf of P1 users, I want to thank you for this improved I2C LCD code.
    Could you point us to an integrated project or code which uses this I2C LCD as display in conjunction with another I2C device (say for example a DS3231 RTC)?
    Many thanks in advance.

  • I'm not feeling well and only got a couple hours sleep last night, yet still did this in about 20 minutes. Give yourself a pep talk and try on your own -- you'll learn a lot.

  • Many thanks Jon...

  • Many thanks Jon,
    I have ordered the I2C lcd and I will work on this project and other I2C devices when it arrives.
    Previously I was using a serial backpack lcd but they are expensive and troublesome with 3v3 serial.

  • Jon, I changed the line LCD_ADDR = %111 to LCD_ADDR = $27

  • JonnyMacJonnyMac Posts: 9,104
    edited 2022-01-30 01:31

    You can only have eight PCF8574 chips on one I2C bus (which is why there are only three address bits on the LCD backpack), so the legal limit for the address is 7 (%111). The address is not the same as the slave ID. The underlying driver merges the discrete device address with the device type to form the slave ID. If you look carefully at the core driver, there are two PCF8574 device types: PCF8574 and PCF8574A and they have different slave ID bits.

  • Roger that and thanks for the info...

  • I was having problems getting things to work at first but isolated the problem to power to the breadboard I was using. I changed the address thinking I may have fat fingered it. Again, thanks.

Sign In or Register to comment.