So I managed to grab a Purdy LCD sample (thanks to LadyAda’s page) to test Arduino interfacing. The first problem I ran into was that my LCD has two LCD controllers (KS0066 – based on HD44780). Thankfully lega7 faced this issue and modified code to work with a 4 line LCD.

I started with that but decided I wanted to modify his library to provide a few different advantages for my design. First of all, I set it up so the developer could pass the library all of the pins and other variables depending on their specific LCD. I also added a few additional functions including an easy debug function, right scroll function, and number functions.

A lot of this is still under testing so I will update this post as I improve the library and learn more about C/C++/C#. Hopefully it will work with other screens easily. This I have not tested yet as I only have one LCD at the moment. Its all kind of crazy at the moment because my background in programming is non-existent. I can read code but don’t know if I’m writing it properly yet. Then again, thats what I like about microcontrollers. I can build circuits and code and actually see it happen. Its definitely got me interested again in becoming a better programmer and engineer.

So anyway, moving on…Here is the Arduino code I’m currently working with.

#include <LCD4Bit.h>

// Constants
#define DEBUG_LED = 13;

// Variables: Program definitions for user configurable settings.
int lcdRows = 4;
int charactersPerLine = 52;
int dotFormatPtn = 0×00;      //5×7 dots.  0×04 is 5×10
int usingRW = false;
int registerSelect = 6;
int readWrite = 7;
int enablePin1 = 0;
int enablePin2 = 1;
const int NUM_DB_PINS = 4;
int dataBits[NUM_DB_PINS] = {2, 3, 4, 5};

int test;

LCD4Bit lcd = LCD4Bit(lcdRows, charactersPerLine, dotFormatPtn, usingRW, registerSelect, readWrite, enablePin1, enablePin2, dataBits, NUM_DB_PINS);

void setup(){
  pinMode(13, OUTPUT); //we’ll use the debug LED to output heartbeat
  lcd.init();
  lcd.clear();
  lcd.cursorTo(3,0);  //select second displaycontroller, line 3, 4
  lcd.init();
  lcd.clear();
  }
 
void loop(){
  digitalWrite(13, HIGH); //light the debug LED
  lcd.cursorTo(1,0);
  lcd.printIn("WTF is up with this");

  lcd.cursorTo(2,10);
  lcd.printIn("Num of Lines: ");
  char buf[3];
  //lcd.printIn(itoa(charactersPerLine, buf, 16));
  lcd.numberWrite(charactersPerLine);
  lcd.cursorTo(3,0);
  lcd.printIn("To Visual C++ I go.");
  lcd.cursorTo(4,0);
 

    lcd.printIn(itoa(25, buf, 16));
 
  /* lcd.printIn("Debug: ");
  lcd.debugVariables(); */
  delay(1000);
  lcd.cursorTo(1,0); // select first two rows
  lcd.leftScroll(40, 80); //scroll first two rows
  //lcd.cursorTo(3,0); //select second displaycontroller, line 3, 4 
  //lcd.leftScroll(40, 80); //scroll third and fourth row
  delay(5000);
  digitalWrite(13, LOW);

  }

And I’ve zipped up and attached the current modification to the LCD4Bit library. Again, this is so not ready for anything serious. I need to add comments to the Wiring code and work a lot more on the library. I’ll work on all that.

My next major mod to the LCD4Bit code will be to get it working properly with a shift register. This is important as I need to keep Arduino pin usage to a bare minimum to ensure there is also room for Xbee, RFID, a keypad, and GPS.

Haha, this will definitely be interesting.

del.icio.us:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library digg:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library spurl:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library wists:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library simpy:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library newsvine:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library blinklist:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library furl:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library reddit:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library fark:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library blogmarks:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library Y!:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library smarking:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library magnolia:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library segnalo:Interfacing Arduino with a Purdy LCD (4x40) - Modified LCD4Bit Library

7 Responses to “Interfacing Arduino with a Purdy LCD (4×40) – Modified LCD4Bit Library”

  1. on 14 Jan 2009 at 1:50 am MichaelKurdziel » Beginning Arduino

    [...] started playing with my Arduino micro. Rewrote the LCD4Bit library to work with an old HD44780-based 40×4 character LCD I had laying around. [...]

  2. on 03 Mar 2009 at 7:12 pm TheKidd

    Hey Michael. I just took a look at your site. Kewl stuff you are doing with remote lighting!

  3. on 10 Dec 2010 at 9:04 pm Mok

    Good info. They must be something value. Thanks

  4. on 30 Dec 2010 at 12:15 am Shafe

    bilgisayar tamiriweb tasar?m
    web hostingtwindows hosting
    linux hostinglinux web hosting
    laptop tamirbilgisayar servis
    notebook tamir
    anakart tamir
    web dizayn
    e-ticaret

  5. on 06 Jan 2011 at 9:09 am Boeck

    Very nice post. I just stumbled upon your blog and wished to say that I’ve really enjoyed surfing around your blog posts. After all I’ll be subscribing to your rss feed and I hope you write again soon!

  6. on 07 Jan 2011 at 2:06 pm Pechar

    Hello, I am a Web Developer and Mobile Hardware & Mobile Software expert.
    I have been a full time internet Article writter for 4 years now.
    I am grateful to be able to live the lifestyle I enjoy, thanks to the internet.

    Can I post some Guest Article in your site?

  7. on 10 Jan 2011 at 9:56 pm Bill

    Thanks for the library any changes? I am using a ks0066u uP for the LCD. It isn’t working with the regular LCD library

Trackback URI | Comments RSS

Leave a Reply

CommentLuv badge
TekCrack uses CommentLuv Premium, which allows you to use your real name and then @Your Keywords (max of 3 keywords). You will need 3 previously approved comments for this to work. Click on the link above to get your own CL Premium Plugin - the best way to build back links and visitors to your website.

Stop Censorship