Main Site Documentation

16x2 character HD4470 - Cobra 2 - Invalid Socket?


#1

Hi,

Im trying to use the sample code for the 2x16 lcd using Fez Cobra II, and plugging the module into the “1” Y socket on the board but im getting the exception with details of:

“Module Display_HD44780 cannot be used with invalid socket number 1”

My code is:

public static void Main()
        {
            
            Gadgeteer.Modules.GHIElectronics.Display_HD44780 display_HD44780 = new Gadgeteer.Modules.GHIElectronics.Display_HD44780(1);
            // Clears the screen
            display_HD44780.Clear();

            // Prints "_____ World" to the top left of the display
            display_HD44780.PrintString("_____ World!");

            // Places the cursor back at the top left of the screen
            display_HD44780.CursorHome();

            // Bytes to represent the letters in "Hello"
            byte H = (byte)'H';
            byte e = (byte)'e';
            byte l = (byte)'l';
            byte o = (byte)'o';


            // Places 'H' in the blank space where this letter goes
            display_HD44780.Putc(H);

            // Places 'e' in the blank space where this letter goes
            display_HD44780.Putc(e);

            // Places 'l' in the blank space where this letter goes
            display_HD44780.Putc(l);

            // Places 'l' in the blank space where this letter goes
            display_HD44780.Putc(l);

            // Places 'o' in the blank space where this letter goes
            display_HD44780.Putc(o);

            // Turns the bacl=klight off
            display_HD44780.SetBacklight(false);

            Thread.Sleep(1000);

            // Turns the backlight on
            display_HD44780.SetBacklight(true);

        }

What socket number should I be using? Is there a working example for the Cobra II?

Thanks,
Ross.


#2

hi Ross,

looks to me as though you have set up a hybrid console project and added the Gadgeteer bits. I would suggest you create a Gadgeteer app and add Cobra2 and the LCD and try again. You may not have done everything needed to fake up the Gadgeteer behaviour.


#3

PS: I’d add the example code in ProgramStarted of the Gadgeteer app


#4

Yep you nailed it. Working now thanks!