PICAXE 18M2 i2c to PCF8475A/HD44780 based 2x16 LCD Project


New Member

I've built a couple of the directly wired 18M2 to LCD controller boards that use the PICAXE BASIC code and it works fine: a great 1 wire solution! Nevertheless, I wanted to figure out how to use i2c to control one of those cheap 2x16 LCD's with the i2c piggy-back PCB. I looked at all the code I could find in this forum and other sites but nothing worked! At one point I didn't think the 18M2 was even exercising the i2c lines, but Hippy correctly pointed out that I needed to up my O-scope frequency to see it: yep, it's working (yet another "Thanks, Hippy, you ROCK!") So, I decided to start ALMOST from scratch. I buzzed the lines and found great variation between mine and many other available LCD units. I also found that the documentation for the generic HD44780 was a bit ambiguous and or tried to cover too much ground in too much of an abbreviated format for easy interpretation: I have great disdain for technical writers that believe in obfuscated descriptions. Luckily, I found a site that had an example of 8051 assembly code that demonstrated the correct initialization and, very importantly, the correct nibble-byte-strobe relationships (helpful URLs at bottom). Once I understood the strobing requirements things started working. So, without further preamble...

Here are the general steps I took to get a low cost blue LCD with an HD44780 type i2c port expander piggy-back PCB to work with a PICAXE 18M2:

1) Buzz the wiring from the PCF8574A to the LCD and take note of the exact pin-to-pin relationship regarding the bit positions for the LCD's control pins: EN, RS, R/W, BL (BL = Backlight LED)

NOTE: My program is configured to work with the wiring I found on my LCD - which probably will be different on YOUR LCD. In fact, I found many examples where the mode (AKA control) nibble is swapped with the data nibble. Furthermore, some of these PCF8475A piggy-back PCBs might have the R/W tied to GND and/or there may be no BL pin or it might be an NPN or PNP based circuit. You'll need to determine these factors up front or things probably won't work as expected. Especially keep an eye on the R/W pin. If it is there then keep it low (0) all the time as in this program I'll never be reading from the LCD's HD44780 controller chip - I'll only be writing to it.

2) Keep in mind that when using the PICAXE 18M2 i2c protocol there will be a direct relationship between the sent byte and PCF8574A's P0 (LSB) to P7 (MSB) outputs. This is shown in more detail w/in the program itself.

3) CIRCUIT: Wire the 18M2's i2c lines (SDA & SLA) to the corresponding pins on the PCF8574A's piggy-back PCB power/com header. Use a 4K7 resistor to pull each line up to VCC. The 4K7 value is important for correct operation of the i2c bus. Below is a picture of the breadboarded set up. Seriously simple!

4) Wire the 18M2 to your development computer for programing

5) Go through this program and change the control nibble's bit position to corrospond to your LCD/PCF8574A relationship. You may need to change the i2c slave address as I soldered all the address pins for a x70 (%01110000) address on my PCF8574A PCB.

6) Load program and debug if needed.


A word about the program's internal message sub-routines: these have been kept as basic as possible in order to demonstrate, on a bit level, what is going on. Obviously, there are much better ways of coding text such as EEPROM based for/next indexing functions!

BASIC PROGRAM & DOCUMENTATION: The attached BASIC program is internally documented, probably in greater detail then needed, but, what the heck!



Last edited:


Senior Member
Excellent work. As you have found the hard part is suually in figuring out the I2C decoder to LCD pin mapping. Everyone seems to use their own circuit routing and, if it's not exactly right, it usually won't work at all or as expected.