HD44780 issues

Posted on
  • Hi guys,
    I've got a HD44780 LCD character Display Module and I'm trying to get it working with Espruino. I've followed the guide here http://www.espruino.com/HD44780 and installed the HD33780 module, but whenever I run the code I get the following error:

    // My code
    var lcd = require("HD44780").connect(A4,A5,A0,A7,A­2,A3);
    lcd.print("Hello World!");
    
    // Error returned
    >echo(0);
    ERROR: Got ':' expected '(' at line 1 col 94
    {a(51,1);a(50,1);a(40,1);a(12,1);a(6,1);­a(1,1);return{write:a,clear:function(){a­(1,1)},print:function(b){for(var c=0;c<b.length;c++)a(Integer.valueOf(b.c­harAt(c)))},cursor:function(b){a(b?15:14­,1)},setCursor:function(b,c){a(128|[0,64­,20,84][c]+b,1)},createChar:function(b,c­){a(64|(b&7)<<3,1);for(var d=0;8>d;d++)a(c[d]);a(128,1)}}}
                                                                                                  ^
    ERROR: Got function expected ':' at line 1 col 95
    {a(51,1);a(50,1);a(40,1);a(12,1);a(6,1);­a(1,1);return{write:a,clear:function(){a­(1,1)},print:function(b){for(var c=0;c<b.length;c++)a(Integer.valueOf(b.c­harAt(c)))},cursor:function(b){a(b?15:14­,1)},setCursor:function(b,c){a(128|[0,64­,20,84][c]+b,1)},createChar:function(b,c­){a(64|(b&7)<<3,1);for(var d=0;8>d;d++)a(c[d]);a(128,1)}}}
                                                                                                   ^
    at line 1 col 102
    {a(51,1);a(50,1);a(40,1);a(12,1);a(6,1);­a(1,1);return{write:a,clear:function(){a­(1,1)},print:function(b){for(var c=0;c<b.length;c++)a(Integer.valueOf(b.c­harAt(c)))},cursor:function(b){a(b?15:14­,1)},setCursor:function(b,c){a(128|[0,64­,20,84][c]+b,1)},createChar:function(b,c­){a(64|(b&7)<<3,1);for(var d=0;8>d;d++)a(c[d]);a(128,1)}}}
                                                                                                          ^
    in function "HD44780" called from line 1 col 185
    in function "connect" called from line 1 col 55
    ERROR: Using '.' operator on non-object at line 1 col 4
    lcd.print("Hello World!");
        ^
    =undefined
    > 
    

    Do you have any idea what's going wrong here? I've tried writing the module code directly but I get much the same results. What should I try next to fix this?
    Thanks

  • Hi. I'll try this out next week. It's possible it is some issue with the minified module.

    You could try editing the options in the Web IDE so that it loads unminified code first. Just change the order of ['min.js','.js']...

  • Hi Gordon,
    I'm only using the unminifed code from your code example, does espruino minify it on the fly?
    I tried putting all of the module code into the IDE, like this: http://pastebin.com/MatnNmhY

    ERROR: Got ':' expected '(' at line 15 col 12
        print : function(str) {
                ^
    ERROR: Got function expected ':' at line 15 col 14
        print : function(str) {
                  ^
    at line 15 col 21
        print : function(str) {
                         ^
    in function "hd44780" called from line 1 col 26
    ERROR: Using '.' operator on non-object at line 1 col 4
    led.print("Hello World!");
        ^
    =undefined
    

    It looks like a syntax error but there is nothing wrong with it? Any ideas what I should try next?

  • Argh. Yes, sorry - i bet it is a problem with recent Espruino versions (to do with the fact that print is a built in function). I'll look into this, but for now, if you put quotes around print (or rename it) I think it will work.

  • Hi Gordon,
    The new Espruino update has fixed the 'print()' bug but sadly it's still not working for me. I don't get any code errors the display just shows the first row fully blocked and nothing on the second row (see photo below). It is always like this from the moment I plug it in.

    Have I wired something up incorrectly? Here are the pins I'm using:

    var lcd = require("HD44780").connect(A8,A9,A10,A11­,A0,A1);
    

    Any ideas? Is this a code/hardware/wiring issue?

  • I reckon something's wrong with your wiring, because pin A11 isn't even on a pin header :) http://www.espruino.com/ReferenceESPRUIN­OBOARD

    You should be able to use any pins though - although try not to use the 3 that are also used for the LEDs.

    The block of pixels happens when the display powers on - so it could be anything (but at least you know the display is working).

    I just tried again here, and it still works fine (and I tried on a few different sets of pins). I'll update the docs, but these are the connections/code I'm using:

    //                                   rs,en,d4,d5,d6,d7
    var lcd = require("HD44780").connect(A0,A1,C0,C1,C­2,C3);
    lcd.print("Hello World!");
    
    LCD Function Espruino
    1 GND GND
    2 VCC Bat
    3 Contrast GND (or variable resistor)
    4 RS A0
    5 RW GND
    6 EN A1
    7 D0
    8 D1
    9 D2
    10 D3
    11 D4 C0
    12 D5 C1
    13 D6 C2
    14 D7 C3
    15 LED +
    16 LED -

  • Yep my wiring was the problem. All working now, thanks.

  • Great! :) What was it in the end? the RW line?

  • It was my mysterious A11 pin wiring, the C pins work perfect.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

HD44780 issues

Posted by Avatar for Owen @Owen

Actions