Data Logger PCB
Connect header (5×2) to connect to LCD & Keypad extension board.
Use 4 digital line for data transfer to LCD, 3 digital line to control LCD, and 1 analogue line to transfer information of key pressed.
Digital Output Pin: 23, 25, 27, 29, 31, 33, 35 (BackLite, EN, RS, DB4, DB5, DB6, DB7)
Analogue Input Pin: A3 (Keypads)
Power Pin: GND, +5V (see supported function)

/* LCD & Keypad example
Board: DATA LOGER ARDUINO MEGA SHIELD, 24.11.2011, V 1.0.0
Author: Dubravko Penezić 2011, Creative Commons BY-NC-SA
Used pins:
DOP-23, DOP-25, DOP-27, DOP-29, DOP-31, DOP-33, DOP-35, A3
*/
// LCD pins
int BeLi_LCD_pin = 23;
int RS_LCD_pin = 27;
int En_LCD_pin = 25;
int D4_LCD_pin = 29;
int D5_LCD_pin = 31;
int D6_LCD_pin = 33;
int D7_LCD_pin = 35;
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(RS_LCD_pin, En_LCD_pin, D4_LCD_pin, D5_LCD_pin, D6_LCD_pin, D7_LCD_pin);
//Key message
char msgs[6][15] = {"Right Key OK ",
"Up Key OK ",
"Down Key OK ",
"Left Key OK ",
"Select Key OK",
" " };
//Analogue value for key
int adc_key_val[6] ={30, 170, 390, 570, 790, 1024 };
//Number of keys
int NUM_KEYS = 6;
//Analog pin
int aKeyPin = 3;
//other variable
int adc_key_in;
int key=-1;
int oldkey=-1;
void setup() {
pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat
// set up the LCD's number of columns and rows:
pinMode(BeLi_LCD_pin, OUTPUT);
digitalWrite(BeLi_LCD_pin, LOW);
lcd.begin(20, 2);
// Print a message to the LCD.
lcd.print("KEYPAD testing press");
}
void loop() {
adc_key_in = analogRead(aKeyPin); // read the value from the sensor
digitalWrite(13, HIGH);
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) { // if keypress is detected
delay(50); // wait for debounce time
adc_key_in = analogRead(aKeyPin); // read the value from the sensor
key = get_key(adc_key_in); // convert into key press
if (key != oldkey) {
if(key < 5) digitalWrite(BeLi_LCD_pin, HIGH);
else digitalWrite(BeLi_LCD_pin, LOW);
oldkey = key;
if (key >=0){
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(msgs[key]);
lcd.print(" ");
lcd.print(adc_key_in);
}
}
}
//delay(1000);
digitalWrite(13, LOW);
}
// Convert ADC value to key number
int get_key(unsigned int input) {
int k;
for (k = 0; k < NUM_KEYS; k++) {
if (input < adc_key_val[k]) {
return k;
}
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}