But there was one key element of the pager which is till around today, the Liquid Crystal Display. I talked about it in my last post, how many things it was used in today and how long it lasted. But today I would like to talk about how it works and what it can do for you!
The Arduino Microcontroller can be used to drive an LCD Display, it has special libraries in its IDE which help the user print to an LCD more easily. We have to start by importing this library and then declaring an LCD object; when declaring the object we have to state what pins it will be operating on, in this case pins 12, 11, 5, 4, 3 and 2. In the set-up we need to begin communication with the LCD and tell the program what size the screen is (In this case 16 by 2). We are not ready to print to the LCD screen.
We also need to set-up the breadboard so that we have the right connections. Using the headers on the LCD we can plug it into our breadboard and then start connecting up the legs to the correct arduino pins. All the pins are labelled, so we can easily see where we need to place the jump leads. The VCC Pin should connect to 5v, as should the LED+ pin although this needs to go through an 220ohm resistor to protect the back lighting of the display. The VSS Pin, LED- Pin and R/W pin need to connect to ground. Connecting the R/W Pin to ground puts the screen in write mode, meaning we can write to it. Pins 14 to 11 need to be connected to Pins 2 to 5 respectively of the arduino. These pins are used to send the characters across to the screen, they are like data lines. Pins 4 and 6 need to be connected to Pins 12 and 11 respectively of the arduino. Pin 4 on the LCD is the RS Pin, this controls where the "cursor" for printing the characters is on screen. Pin 6 on the LCD is used to enable the display. Finally Pin 3 on the LCD needs to be connected to a potentiometer so that the contrast of the display can be changed. Phew, were finally ready.
Characters can be printed to the LCD using the lcd.print() function. The position of the cursor can be changed using lcd.setCursor() and the screen can be cleared using lcd.clear(). This is all you need to start printing basic strings to the LCD Display. Remember you only have a limited screen size, and the characters do not run over to the next line. You will have to be careful with your choice of words!
An LCD can be used to display all sorts of information, as long as it is in character format. Any text and numbers (as long as they fit on the screen). You can let your imagination run wild! An LCD can even be incorporated into a game so that there is a visual output for the player!
I had great fun doing this project and anyone with an Arduino Starter kit and knowledge of Electronics should give it a try, it really opens up your world and makes lots of new projects available to you! Its also always cool to remember that you are essentially programming the same technology that is used in your TV!
Thanks for reading my ramblings once again! I have no idea what the next project will be, so keep your web browsers open and your microcontrollers on!
Till next time!
Sam