One of the first things I bought to use with my arduino was a 2×16 character display, specifically this one from Adafruit. Playing with it was fine, but after looking at the interface to the LiquidCrystal library I decided to see if I could abuse it by making it into a cheap-o Etch-a-Sketch.
Stage 1 of this project worked fine, and was actually a bit of fun (although it was kind of cheating – I’m supposed to be challenging myself with hardware, and this was really all just programming). I knocked up a couple of trimmers to use as the knobs, whipped up some modulo arithmetic, and I turned my 16×2 character display into a 80×16 pixel display.
Here’s a not-great video of the result:
Next I wanted to make drawing persistent, to be able to actually draw. Seemed simple enough – I had been building custom characters on every update, with the current x,y bit turned on, then writing that char to the correct x,y character position. All I should have to do it maintain an array of characters. Then on each iteration when I set the x,y position, it’s an update, not an entirely new character. Then when I write the character out, I’ll get the entire state for the board.
Unfortunately, this exposed a pretty fundamental misunderstanding I had of the character displays. I assumed that since I was only updating a single “character” at each loop, all the characters I wasn’t touching would just stay put. However, when I re-create the custom character at each loop, that also updates every place on the display that was showing that “character”. It actually looks fairly interesting as, over time, multiple characters on the screen start to come to life and start changing in sympathy with each other. Cool, but not at all what I wanted.
This failure completely makes sense as I think about it. Since the LiquidCrystal library only supports 8 unique custom characters I can’t make use of the whole screen just through the standard library. It’s possible that the 8 character limitation is arbitrary and that I could raise it by mucking around in the library, but that doesn’t sound like that much fun.
There are a couple of possible next steps I could take here:
- Just to show the core of what I wanted to do, use the 8 custom characters I get from the LiquidCrystal library to make a 2×4 character (16×20 pixel) display. I will probably do this and take a video of it just to have done it. One of the original goals in this project was to just make anything that I wasn’t copying from someone else. Ideas include a write/erase function, “status” lights, an “invert” button, a non-state-changing cursor, basically anything to take up a pin on the Arduino. Now that I write this down and remember what my goal was, I’ll probably do this no matter what
- I could track down the LiquidCrystal library and understand what the root of the 8-custom-character limit is. If it’s an arbitrary software limit, maybe raise it and recompile. If it’s not arbitrary but due to memory, maybe make a custom version of the library in which some standard characters are missing, allowing me to use their memory space for more custom chars. I doubt I do this anytime soon, but if I decide to play around more with Arduino libraries, this might be a fun platform to learn more about them.
- If the limit on the number of custom characters turned out (somehow) to be hardware based, then I could skip the LiquidCrystal library altogether and see if I could somehow force the hardware to do what I want if I give up on the need for standard characters. I think the only way I would do this is if I actively needed to learn about the LCD chipset’s low level use for some other reason.
- There’s a strong possibility that I may bag everything above because I had an idea for a new project that I want to get working using my Arduino. Since this is the most interesting thing I’ve made that I haven’t copied form someone else, I should take this opportunity to think about how I will store project information. I’m not fond of the Arduino dev environment’s file system layout requirements and concessions I have to make to it to use SVN, but I do have this sketch in SVN. Need to lean more about creating and storing schematics. Can I store them with the Arduino sketch without the Arduino software complaining? What’s the best software to use? Right now I just want to sketch something out that I can use to recreate the circuit later, and that I can put in version control. ASCII art would work right now, but I wonder if there’s an advantage to finding more specific software this early in my learning cycle…
Right. Disappointed that my original idea didn’t work, but still plenty to learn in that list above. I wonder if I can get 1 and 4 done while waiting for parts for NewProjectIdea?
Hello,
I’m curious how you achieved this? I’ve only been playing with Arduino for a few days but looking through the LiquidCrystal library and I can’t figure out how to draw a single pixel only. Can you share how you did this?
Also, I believe the 8 character limit is hardware-based. The chipsets used in the LCD’s are quite dated in their design and don’t have a lot of RAM, able only to store 8 characters. This is discussed here:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1270591606
Cheers
Aaron, thanks for the link about the LCD chipset and the custom characters – now I won’t walk up that alley.
As for how I did the single-pixel drawing in that video, I’m not 100% sure which part you’re having trouble with so I’ll outline the basics of what I did:
1) I only ever need to turn a single pixel on at one time, so all I need is a single custom character at a time, I just redefine it every loop
2) I broke the x,y down into two pieces. The first is the character position, on the native 16×2 character grid. The second is the pixel position, on an 8×5 pixel grid that each character is made of. These are calculated using the trimmer pot positions and some modulo arithmetic.
3) At each loop:
– Calculate char x,y and pixel x,y based on the pot position
– blank the display
– redefine custom char 0 using the new pixel x,y information
– write custom char 0 out to the new char x,y position
Hope that helps. I can dig the code back out if you really want to see it.
I want to see it!
No need, that’s really helpful. And quite obvious now:P
Thanks!
Pingback: » More Character Display Abuse Great Hat…