The examples I found did not work with C# or were for the 74HC595.
I found the μLiquidCrystal library but it did not have a class for my chip. After looking at the MCP23008 Expander class, it looked like I could just re-assign the pins to mine.
So I create two new classes based on the MCP23008 and gave it a try.
Which did end up working. If you want to build this, you need to download the μLiquidCrystal library and save the two class files into the same folder as the MCP2003Exander.cs file.
You also need to add a Reference to the MicroLiquidCrystal project.
Here is a quick way to test it (Hopefully it is quick.).
-Download the uLiquidCrystal Library.
-Open the MicroLiquidCrystal.sln file. Ignore some errors about the 'Example' project path.
-From within Visual Studio, Right Click on the 'Solution MicroLiquidCrystal (X Project)' from the Solution Explorer window and select 'Add New Project.'
-Open the new Program.cs file and paste this code in.
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; using FusionWare.SPOT.Hardware; using MicroLiquidCrystal; using System.Text; using Microsoft.SPOT.Net.NetworkInformation; namespace PCF8574ClockTest { public class Program { private static Lcd _lcd; private static I2CBus _bus; private static Timer _lcdTimer; public static void Main() { _bus = new I2CBus(); // initialize provider (multiple devices can be attached to same bus) var lcdProvider = new PCF8574LcdTransferProvider (_bus); // create the LCD interface _lcd = new Lcd(lcdProvider); _lcd.Backlight = true; // set up the LCD's number of columns and rows: _lcd.Begin(16, 2); // this again to reset. // Print a message to the LCD. _lcd.Write("Netduino clock"); _lcdTimer = new Timer(UpdateDisplay, null, 500, 500); Thread.Sleep(Timeout.Infinite); } static readonly byte[] _lineBuffer = new byte[16]; private static byte[] FillLine(string text) { // fill empty space for (int i = 0; i < _lineBuffer.Length; i++) _lineBuffer[i] = (byte)' '; // write new text var bytes = Encoding.UTF8.GetBytes(text); bytes.CopyTo(_lineBuffer, 0); return _lineBuffer; } private static void UpdateDisplay(object state) { var dt = DateTime.Now; // write time _lcd.Home(); _lcd.Write(FillLine(dt.ToString("hh:mm:ss")), 0, 16); // write date _lcd.SetCursorPosition(0, 1); _lcd.Write(FillLine(dt.ToString("MM/dd/yyyy")), 0,16); } } }-Right click on 'Add Reference' for your project and select the Projects tab, then 'MicroLiquidCrystal'.
You should now be able to run it.
Also, my PCF8574 may have a different address than yours, you can change the address in the 'PCF8574Expander.cs' class.
Hopefully I did not mess a step an this helps someone!
HELP!!!
One odditity I did notice, after leaving the clock run for a while, intermittently my display with show garbage.
I added a little routine to my onboard switch that sends a _lcd.Begin(16, 2); command to restart it all.
I have no clue why this does this and I wish I knew how to prevent it.
When I created my LED test with the PCF8574, I left the LEDs plugged in when attaching to the LCD.
It does show me that even though the display is showing garbage, the LEDs are lighting on/off just like they do when it is displaying correctly.
Maybe the LEDs are causing some interference after a while. I plan on making a board and will have a better test outside of a breadboard setup.
Good luck!
Trey Aughenbaugh