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

Trackback URI | Comments RSS

Leave a Reply