Sunday, May 1, 2011

Arduino - A/D conversion and LCD Interfacing

Basically, this project is meant to simultaneously test the A/D conversion and LCD driving capabilities of the Arduino platform. Turning the potentiometer will vary the number displayed on the LCD between 0 and 1023.

What you will need:

1 x Arduino Board
1 x HD44780-compliant LCD module
1 x Potentiometer (I used a 10K linear here)

The Setup

(Center pin to pin A5 on the board, side pins to ground and +5v.)

We will be driving the LCD module by 6 data pins here.

In this case, I connected them as follows:

LCD ">"> Arduino Pin
D7 2
D6 3
D5 4
D5 5
RS 12
Enable 10

Also, connect the R/W pin of the LCD module to ground.

Some serious 6 pin LCD drivin', yo!

(Vss to ground, Vcc to +5v, Vlc to ground via a 4.7K resistor[contrast])

The code below should work pretty well:
(See the LiquidCrystal() library on the Arduino website for more detailed info)


#include <LiquidCrystal.h>

int sensorPin = A5;
int sensorValue = 0;

LiquidCrystal lcd(12, 10, 5, 4, 3, 2);

void setup()

void loop() {
sensorValue = analogRead(sensorPin);


(Here we can see the 4.7k resistor I used to set the contrast of the LCD module)