Skip to main content

InduinoX: Interfacing with LCD

After my quick Hello World app, I became a bit more adventurous and decided to interface with the LCD screen that was part of the basic kit from Simple Labs (see this post for more details). Fortunately, arduino has a library called LiquidCrystal to interface with LCD displays that are driven by Hitachi HD44780 compatible drivers. All you have to do is add a #include <LiquidCrystal.h> in your code to start using the library.

But before going into the coding part, I had to first make the proper connections from the LCD display to the arduino board. I looked up the datasheet for my LCD display, but found a much simpler connection diagram over at http://www.arduino.cc/en/Tutorial/LiquidCrystal. I did not make the exact connections like in the diagram. This is what I did

LCD                            Arduino
PIN 1 (GND)                    GND
PIN 2 (Vcc)                    +5V
PIN 3 (Contrast adjustment)    Voltage divider (see below)
PIN 4 (Register select)        Digital PIN 13
PIN 5 (R/W signal)             GND
PIN 6 (Enable signal)          Digital PIN 12
PIN 7 (Data bus line)
PIN 8 (Data bus line)
PIN 9 (Data bus line)
PIN 10 (Data bus line)
PIN 11 (Data bus line)         Digital PIN 11
PIN 12 (Data bus line)         Digital PIN 10
PIN 13 (Data bus line)         Digital PIN 9
PIN 14 (Data bus line)         Digital PIN 8
PIN 15
PIN 16

Pins 7, 8, 9, 10, 15 and 16 are not connected to the arduino board. Pin 3 was supposed to be connected to a 10K pot, but since I did not have a pot, I had to do a voltage divider circuit. I tried out 1K, 10K divider circuit, with output of the 1K ohm resistor connected to pin 3. This gave me the correct contrast! Although the LCD display has 8 data lines it can be driven with only 4 lines with a lower refresh rate and the arduino library can communicate over the 4 lines. Now that the connections are done, back to programming.  Here is the code

#include <LiquidCrystal.h>

LiquidCrystal lcd(13, 12, 11, 10, 9, 8);

void setup() {


  // Setup LCD's number of columns and rows
  lcd.begin(16, 2);
  
  // Print a message to LCD
  lcd.print("hello");
}

// a function which executes again and again
void loop() {
}

Very simple app that displays "hello" on the LCD screen.


If you want the backlight of the LCD screen to turn on, connect pin 15 to +5V with a limiting resistor and pin 16 to ground.

Comments

ubadahoch said…
How to get to the casino - DrmCD
You'll need to enter your personal information in 춘천 출장샵 order to 평택 출장샵 access the hotel. The process is quite simple. Once you're done, 강원도 출장샵 navigate to 과천 출장샵 the homepage of the website. Click on 충청남도 출장마사지

Popular posts from this blog

Attesting General Power of Attorney in SF

Recently I had to go through the motions of getting a General Power of Attorney (GPA) document attested in San Francisco. I am an Indian by birth. My parents were trying to buy a house back in India for me. Since I did not want to travel to India they needed a GPA so that they can act on my behalf to sign all the documents required to buy the house. The problem however is that they needed it urgently because the seller lives in UK and wants to get all the things done quickly so he can go back. My parents send me a GPA document that they obtained from a lawyer. This is a document that will give the power to my parents to buy the said property in the document on my behalf. The lawyer said that I will have to get the document attested at an Indian Consulate in USA. The closest one for me is in SF and I can drive there in about an hour from where I live. So I though it will be like a day's work to get all the things done. I looked up at their  website  for the procedure to att

XBMC / Boxee remote control android app

I have been writing a few android apps over weekends at home and during 20% time at Google. However I never actually released any of them in the android market mainly because they were quick and dirty apps that fit my needs but perhaps would not be appealing to the general public. One such app that I quickly wrote over a couple of weekends is a XBMC remote. The media center that I use at home is XBMC and I have always wanted to have more control and faster access to my media. Using my remote to navigate through the menus is not as fast. Especially when I wanted to queue a lot of music it is very slow. So I wrote this nice little app called "XBMC remote" for my android phone to control XBMC from anywhere :). Give it a try. Search for "xbmc" in android market and install it if you use XBMC as your media center. When you first launch the app you will start with this screen. You will have to setup your web server address, username and password (if required) by

gtkdocize not found

If you are ever configuring an app and see the message "gtkdocize not found" in Gentoo, then you need to emerge gtk-doc. I had some hard time figuring this out so I am writing it in my blog for the next time. When I saw that error message I did an "emerge -s gtkdocize". Usually it is that simple in Gentoo. But not this time. The emerge command returned no results at all. Then I searched for gtkdoc and still no luck. After searching in Google, I still did not have a solution. After thinking for a while I decided to try to search for gtk-doc. Bingo! That worked! Interestingly, this is my first post from my Virtual machine :-)