LCD input output expansion board uses 2 lines and 16 characters LCD, which has a contrast adjustment and backlight. Use 1 analog port to complete the input of 5 keys, 1 reset button, and the unused IO ports are expanded to set aside, and make full use of it.IO port.Occupy digital port: PIN4 (DB4), 5 (DB5), 6 (DB6), 7 (DB7), 8 (RS), 9 (E), 10 (backlight control), simulation key port A0EssenceUse it with Arduino:
Point definition:
Debugging of the module:
insert LCD keypad shield to the Arduino controller, and then downloadLCD4Bit_mod.h(Right-click another) library file to -0015 \ Hardware \ libraries, then compile a test program below and download it to Arduino. The LCD is for the first time.Correctly, you can use a word to adjust the RP1 (rotating clockwise), and you can adjust it to a clear character.
Professional anti -static packaging
Test renderings:
GP2D12 ranging code:
#include
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;
}
Template protection code
Template protection code