Using Arduino Analog Pins to Interact with LCD
Following the arduino tutorial, http://arduino.cc/en/Tutorial/AnalogInputPins it was quite clear that the Analog Pins can be used as its Digital counterpart. Except with a little different way of identification, i.e. prefixing the respective Analog pin with the character 'A' (A for Analog).
The significance of this feature was overlooked until recently I desperately needed numerous digital pins, and I ran out of them on my Arduino (Atmega328) clone to drive Hitachi HD44780 compatible LCD.
People suggested to use shift registers or I2C backpack etc., though, I wanted something more simpler and ultimately following the below mentioned tweaking, I got the LCD up and running using Analog pins. No rocket science, but felt happy, as I had saved my pocket from the extra expenses!!!
Display
|
Original
|
Our Experiment
|
RS
|
12
|
A0
|
RW
|
GND
|
GND
|
EN
|
11
|
A1
|
D4
|
5
|
A2
|
D5
|
4
|
A3
|
D6
|
3
|
A4
|
D7
|
2
|
A5
|
At the same time the code needs to be slightly changed, shown as below.
// Replace LiquidCrystal lcd(12, 11, 5, 4, 3, 2); with
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
This shall use all Analog pins, though, the user is spared with all digital pins free, if the it is the sketch's demand .
No comments:
Post a Comment