Arduino + Crystalfontz Serial LCD + buttons!

I've been dreaming and thinking about a custom hardware interface to control my visuals. In stead of using a mouse to select parameters and change values, a dedicated controller would be a much better way to do my thing. I discovered Arduino a couple of months ago and after reading a massive amount of information about the hardware and software I decided to buy a board myself to see how far it would get me.

So last week I ordered a board from PCB Europe in Italy and I received it only 3 days later (The Netherlands). The first things I did were some standard tutorials like fading a RGB led and reading potentiometer values through hyperterminal to get familiar with everything.

After playing with Arduino for one day I think that it will suit my needs for the controller! Today I've read the Serial LCD Tutorial by DJmatic and decided to dust-off one of the LCD's that I had lying around for a couple of years.

I have the Crystalfontz CFA-643 (site, datasheet), 4x20, blue/white, with serial and USB interface. The small USB shield was mounted on the serial I/O headers, so I had to take that off first. I could have used the normal DB9 serialport that is mounted on the back, but that required a voltage between 9 and 15 volts. The serial I/O header takes 5 volts, as it's powered by USB.

I started with the code made by DJmatic, but rewrote almost every single line of code to make it work with the CF display. The display has some nice built-in routines for displaying bar graphs, very large fonts and custom characters. It's also one of the biggest 4 x 20 LCD's I've ever seen.

Interfacing the LCD with Arduino was really simple, just 4 wires! The hard part was connecting 2 input buttons to Arduino (due to the lack of a schematic or high rez picture on the button tutorial page), but I finally learnt what a pull-down resistor is, and how to connect it. :wink: I will update the tutorial page for other newbies once I have been granted contributor access to the wiki.

The buttons will allow me to access menus, select functions and change values of a wide range of parameters that are available in the software. The final controller will feature buttons, sliders, LED's and rotary encoders. The LCD will be used to show the parameters and their values.

So here's a picture of what I've managed to put together so far:

(larger version)

And a movie to see it in action: Quicktime (16,5mb)

I will contribute the code library for the Crystalfontz serial LCD once I have implemented all features and thoroughly tested it. A tutorial is also on its way...

Many thanks to the Arduino team and the community for making this possible..

Wow, great work!

I was thinking about getting one of those LCDs, I can't wait for examples!

I second the notion; I would love to see your code!
I've spent all weekend frustratedly looking at garbage coming out of my 643.
Even if it's rough I'm sure it would help a lot of us!
Thanks!

HOLY #@%$ THATS A HUGE SCREEN! it could hold soo much information, so much! the power, the greatness, THE FREEDOM! NO MORE 16 x 2 CRAP!

more like 100 x 100 with that screen lol

i triple that notion!

I'll dig up the code and clean it up a bit.. I'm also working on a small howto/hook-up guide.. Stay tuned :wink:

I'm REALLY not trying to "rain on the parade".... I think the work done is great, and I've chased such things myself.... but.... for people thinking of adding an LCD display....

CrystalFontz: About $60? (for one like the one pictured in this thread)

Alternative: Serial controller, which is already working at microcontroller levels... no RS232 "stuff" to sort out, as with CrystalFontz.... $8,

To which you have to add the LCD display of your choice: Either a simple 2 lines of 20 characters and no backlight (cheap), or as big and as beautifully lit as your budget allows (within reason! You won't get 40 lines of 80 characters... I don't think...)

The alternative described in more detail at....

... and no, I don't participate in the profits. Just a happy customer. (Profits??? At $8? This is just a fellow hobbyist sharing at cost, I think.)

Yeah its very pricey. I can get several large LCD panels for that price.

And with my OpenLCD which is being developed, you get a hardware accelerated, I2C, Serial (TTY and RS232) and SPI, LCD controller which can do all kinds of fancy tricks for $10. </shameless plug> :wink:

XNDR: what are your jumper settings?
thx!

FWIW, the Crystalfontz display needs to have jumpers JPE and JPB closed. 0 to +5v, with inverted levels.

Here's some sample code to read a pot and display a bargraph.

// cheap hack to read pot data
// it uses averaging to smooth out data over time, as well as hysteresis(?)
// to make sure it is a signifigant change.
// it only updates the display on changes to pot readings, so it looks much smoother.

int count = 0; // for looping
int delayTime = 500; // unused i think
int val = 0; // pot value
int hyst = 1; // mount of hysteresis
int oldVal = 0; // to remember previous pot value
void setup() {
  Serial.begin(9600); 
  Serial.print(004, BYTE); //turn off blinking cursor
}

void loop() {
  val=0;
  for (count = 0; count < 10; count++) { //loops 10 times 
    val = val + analogRead(0); //adds the pot readings together
  }

  val = (val / 100)*1.18; // finds average of readings and scales from 0-1020 to 0-120
  if (val < (oldVal - hyst)) // if variance is less than hyst
  {
    oldVal = val; //set oldVal to val
    LCDBarGraph();
  }
  else if (val > (oldVal + hyst)) // if variance is more than hyst
  {
    oldVal = val; // set oldVal to val
    LCDBarGraph();
  }
  else { // variance is below hyst  IS THIS ELSE NEEDED
    val = oldVal; // keep oldVal
  }  


}

void LCDBarGraph() {
  Serial.print(12, BYTE); // clear lcd
  Serial.print(13, BYTE); //align left
  Serial.print(18, BYTE); //create bargraph
  Serial.print(000, BYTE); //custom character
  Serial.print(255, BYTE); //bar type
  Serial.print(000, BYTE); //start column (0-19)
  Serial.print(19, BYTE); //end column  (0-19, must be higher than start)
  Serial.print(val, BYTE); //length in pixels 0-120
  Serial.print(002, BYTE); //y position (000-003)
}

Check out my site for more ill thought out hacks http://blog.tinyenormous.com

Am new in microcontrolers but am now having a project and i have decided to use arduino decimila and whats to use SFE Basic 16 x 2 Character LCD STN- Black On Green. The screen have got pins and i have been unable to select the RX pin and the data GRD. Anyone with the idea how to interface this kind of LCD with Arduino? If possible assist me with simple code for simple display demo!

From the site 'Arduino Playground - LCD3wires' it seems like i must use a driver? Is there a way to connect directly to the arduino with the driver?
Please help...

Mturuchiu -
If you look at the page you bought that lcd from it has everything you need.
Datasheet, pin assignment, schematic, and source code.

And to answer your other question. Once you get this wired up and programmed correctly, you should only need to print characters from the arduino tx to the lcd rx and they ought to show up.

good luck!