Shop OBEX P1 Docs P2 Docs Learn Events
How do I program an LCD using Propeller C? — Parallax Forums

How do I program an LCD using Propeller C?

ValeTValeT Posts: 308
edited 2014-11-06 16:55 in Propeller 1
I have looked around a little on Learn.Parallax.com, and can't find a way to program an LCD using Propeller C. I have found the place that you go to program an LCD, but it doesn't contain anything about programming it in C.

Can anybody here guide me in the right direction?

Thanks,
ValeT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-11-06 16:09
    The answer to this would depend greatly on the type of LCD. Is it a character or graphics LCD? Serial or Parallel interface? If serial you can just use the serial library and send the appropriate commands from the datasheet to control it.
  • Hal AlbachHal Albach Posts: 747
    edited 2014-11-06 16:24
    If it is a character type LCD you might want to look at Modern Devices web site for a kit that will convert your LCD to a serial LCD. http://moderndevice.com/product/lcd117-serial-lcd-kit/. I use them on all my LCD's, it sure takes the tedium out of displaying your data. If you use the LCD as a parallel device it will consume from 6 to 14 I/O pins. Sometimes just getting the LCD to initialize can become very frustrating. The serial ones takes care of all the details.
  • ValeTValeT Posts: 308
    edited 2014-11-06 16:32
    Thanks for the help so fast!

    I have now checked and know it is serial, so I will just use the serial library to communicate with it.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-11-06 16:55
    @ValeT, I know you already have your solution but this looks like a great place to advertise PropWare's HD44780 class.

    For those using parallel character LCDs (aka, the HD44780 standard), feel free to use PropWare's HD44780 object! It makes using them really simple and easy! :D

    Class documentation: http://david.zemon.name/PropWare/classPropWare_1_1HD44780.html
    Example program: http://david.zemon.name/PropWare/HD44780__Demo_8cpp_source.html
    #include <PropWare/PropWare.h>
    #include <PropWare/printer.h>
    #include <PropWare/hd44780.h>
    
    // Control pins
    const PropWare::Port::Mask RS = PropWare::Port::P16;
    const PropWare::Port::Mask RW = PropWare::Port::P17;
    const PropWare::Port::Mask EN = PropWare::Port::P18;
    
    // Data pins
    const PropWare::Port::Mask          FIRST_DATA_PIN = PropWare::Port::P19;
    const PropWare::HD44780::Bitmode    BITMODE        = PropWare::HD44780::BM_8;
    const PropWare::HD44780::Dimensions DIMENSIONS     = PropWare::HD44780::DIM_16x2;
    
    // Main function
    int main () {
        // Create and initialize our LCD object
        PropWare::HD44780 lcd;
        lcd.start(FIRST_DATA_PIN, RS, RW, EN, BITMODE, DIMENSIONS);
    
        // Create a printer for easy, formatted writing to the LCD
        PropWare::Printer lcdPrinter(&lcd);
    
        // Print to the LCD (exactly 32 characters so that we fill up both lines)
        lcdPrinter.printf("%u %s%d 0x%07X", 123456789, "Hello!", -12345, 0xabcdef);
    
        return 0;
    }
    
Sign In or Register to comment.