Specifications
LCD Keypad Shield, input and output expansion board using the 2 line 16 character LCD with contrast adjustment and backlight, the use of an analog port will be completed in five key input, a reset button, and extended out of the spare unused IO port,make full use of the IO port. Occupy any digital port: PIN4 (DB4), 5 (DB5), 6 (DB6), 7 (DB7), 8 (RS), 9 (E), 10 (backlight control), to simulate the key port A0. Used in conjunction with the Arduino:
Pin definitions:
The debugging of the module:
LCD Keypad Shield, inserted received the Arduino controller, and then need to download the library files to the Arduino-0015 \\ hardware \\ libraries LCD4Bit_mod.h (Save as), and then compile the following test procedures and then downloaded to the Arduino, the initial LCD Keypad Shield, the first observation of the LCD does not show character, if there is no display character is incorrect contrast, you can use a flathead screwdriver to adjust RP1 (clockwise rotation), transferred to clear character can.
Professional anti-static packaging
GP2D12 Ranging code:
#include <LCD4Bit_mod.h>
LCD4Bit_mod lcd = LCD4Bit_mod(2);
char GP2D12;
char a,b;
char str1[]="Renge:";
char str2[]=" Renge Over ";
char str3[]="cm";
void setup()
{
lcd.init();
lcd.clear();
lcd.printIn("GP2D12 testing...");
}
void loop()
{
GP2D12=read_gp2d12_range(1);
if(GP2D12>80||GP2D12<10)
{
lcd.cursorTo(2,0);
lcd.printIn(str2);
}
else
{
a=0x30+GP2D12/10;
b=0x30+GP2D12%10;
lcd.cursorTo(2, 3);
lcd.printIn(str1);
lcd.print(a);
lcd.print(b);
lcd.printIn(str3);
}
delay(50);
}
float read_gp2d12_range(byte pin)
{
int tmp;
tmp = analogRead(pin);
if (tmp < 3)return -1;
return (6787.0 /((float)tmp - 3.0)) - 4.0;
}