รู้จักสินค้านี้
หน้าจอพร้อมปุ่มกด LCD แบบ Shield บน Arduino
ตำแหน่งขาต่างๆ
Pin Function
Analog 0 Button (select, up, right, down and left)
Digital 4 DB4
Digital 5 DB5
Digital 6 DB6
Digital 7 DB7
Digital 8 RS (Data or Signal Display Selection)
Digital 9 Enable
Digital 10 Backlit Control
ตัวอย่าง Code การใช้งาน หน้าจอพร้อมปุ่มกด LCD แบบ Shield บน Arduino กับ Uno r3
/** * www.ModuleMore.com * ตัวอย่างการใช้งาน Shield LCD พร้อมปุ่มกด */ #include Arduino.h #include Wire.h #include LiquidCrystal.h const int LCD_RS = 8; const int LCD_EN = 9; const int LCD_D0 = 4; const int LCD_D1 = 5; const int LCD_D2 = 6; const int LCD_D3 = 7; const int BUTTON_INPUT = A0; // const int LCD_BLACKLIGHT = 10; LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D0, LCD_D1, LCD_D2, LCD_D3); void setup() { lcd.begin(16, 2); lcd.setCursor(0, 0); lcd.print("ModuleMore.com"); lcd.setCursor(0, 1); lcd.print("Press Key:"); } void loop() { int val = analogRead(BUTTON_INPUT); lcd.setCursor(10, 1); if (val 60) { lcd.print("Right "); } else if (val 200) { lcd.print("Up "); } else if (val 400) { lcd.print("Down "); } else if (val 600) { lcd.print("Left "); } else if (val 800) { lcd.print("Select"); } }