Vous êtes sur la page 1sur 6
sors2015 Ardino LCD KeyPad Shield (SKU: OF ROOD) - Rober Wiki Arduino LCD KeyPad Shield (SKU: DFR0009) From Robot Wiki Contents = [Introduction 2 Diagram 3 Pin Allocation 4 Sample Code = 4.1 Example use of LiguidCrystal library = 4.2 Example use of Enhanced LiquidCrystal_I2C library(Not updated) 5 Documents Introduction The LCD Keypad shield is developed for Arduino compatible boards, to provide a user-friendly interface that allows users to go through the menu, make selections etc. It consists of a 1602 white character blue backlight LCD. The keypad consists of 5 keys — select, up, right, down and left. To save the digital [0 pins, the keypad interface uses only one ADC channel. The key value is read through a 5 stage voltage divider. Note: Version 1.1 main updates are the button values, which have being updated on the example code. For older version check the comments and edit, or use the Enhanced V1.0 library Arduino LCD KeyPad Shield (SKU: DFR0009) ip shwarw robot camiwikiindex.sb\Aréuina_LCD_KeyPad_ Stile (SKU:_DFRo008) 6 10182015 ‘Arouino LCD KeyPad Shield (SKU: DF ROD) - Robot Wik Diagram Leo Contrast Potentiometer ese ace hx newer 5 Koys connectto Analog Input Pind LCD&Keypad Shield Diagram senor Pin Out Diagram Pin Allocation ip hwarw robot comiwikilindex sp\Aréuine_LCD_KeyPad_ Stile (SKU: DFRO00S) sors2015 ‘Arduino LCD KeyPad Shield (SKU: OFROOD) - Robt Wiki Pin Function Analog | Button (select, up, right, down and left) Digital 4 DB4 Digital 5 DBS Digital 6 DB6 Digital 7 DB7 Digital 8 RS (Data or Signal Display Selection) Digital 9 Enable Digital 10 Backlit Control Sample Code Example use of LiquidCrystal library {sample using iquiderystal Library Feinctuge eLiqutecrystal h> his program will test the LCD panel and the buttons lark Bramwell, July 2010 ateereeensestisnensntstneseensenesentisnsssnesenenenet / define sone values used by the panel and buttons int led key = 85 int ade_key_in = 0; define bEnRIGHT @ define benuP 1 define bEnDOKN 2 define bEnLEFT 3 define bENSELECT 4 define bEMNONE 5 | read the buttons int read_LcD_buttons() ‘adc_key_in = analogkead(@);_// read the value from the sensor 7/ fy buttons when read are centered at these valies: @, 144, 329, S@4, 741 11. we acd approx 5@ to those values and check to see if we are close Af (ade_key_in > 1008) retura BEMNONE; // We make this the 1st option for speed reasons since it will be the most 11k 1/ For Vi.1us this threshold if (adc_key_in < 58) return bEnRIGHT; Af (ade_key_in < 258) return benUP; if (adc_key“in < 450) return btnDoW\; if (adc_key"in < 650) return bUnLEFT; if (ade_key“in < 850) return bEnSELECT; ip hwwr robot camiwikiindex.shp\Aréuina_LCD_KeyPad_ Stile (SKU:_DFRo008) a6 10182015 if (ade_key_in if (ade_keyin if (ade_key“in if (ade_keyin / oid setup() -begin(18, 2); u -setcursor(@,e); print (“Push ‘the buttons"); // Le0p() ed. setcursor(9,1); uv led.print(millis()/1000);// led. setcurson(@,1); uw led_key = read LcO_buttons();// switch (1ed_key) uw « 1 case benriGHT: Po 1 Ied.pring(*RIGHT "); | brea Poy case btnLeFT: { Led.print ("LEFT"); beat y case benur: € Led.print ("UP break; ) case benbowN: { Led.print("DOWN *); break; ? case bEnSELECT: { Led. print("SELECT"); break; ? ‘case btnNONE: { ed.print ("NONE"); breaks > ‘Arcuino LCD KeyPad Shield (SKU: DF R000) - Robot Wiki 1.11 For v1.8 comment the other threshold and use the one below: < 58) return btnRzGHT; < 195) return benUPs if (adc_key"in < 380) return btnDowi; < 555) return DENLEFT; < 730) return bENSELECTS return BtMNONE; // when all others fail, return this... start the Library print a simple message ove cursor to second line "1" and 9 spaces over display seconds elapsed since power-up ove to the begining of the second line read the buttons depending on which button was pushed, we perform an action ip hwarw robot comiwikilindex sp\Aréuine_LCD_KeyPad_ Stile (SKU: DFRO00S) sors2015 Ardino LCD KeyPad Shield (SKU: OF ROOD) - Rober Wiki Example use of Enhanced LiquidCrystal_I2C library(Not updated) This library inherits LiquidCrystal and adds another method: button - to read button pushed on a keypad, This works on the Old version of the board V1.0 Library Forum (http://www. dfrobot.com/forum/index.php?topie=3 1.0) ‘ttp: //wm.sourceforge.net/users/ecefixer Yttp://ecefixer.tunblr.con sisplays the currently pressed key on the LCD screen. fey Codes (in left-to-right order) ieinclude leinclude {y7ein assignments for oFRobot LCD Keypad Shield iquidcrystal 1c6(8, 9, 4, 5, 6, 7) led. clear(); led. setcursor(@, 2) led. print ("Key Grab v8.2"); delay(2500); I (OPTIONAL keypad. setRate(x); Sets the sample rate at once every x milliseconds: Default: 1m 7 keypad. setRate(1e); > void t00P0 a keypad. gerxey()s Grabs the current key Returns a non-zero integer corresponding to the pressed key, on hip hwarw robot camiwikiindex.shp\Aréuina_LCD_KoyPad_ Stile (SKU:_DFRo008) sors2015 Ardino LCD KeyPad Shield (SKU: OF ROOD) - Rober Wiki Returns @ for no keys pressed, 1 or } Returns -1 (sample wait) when no key is available to be sanpled. " localkey = keypad. getkey(); Af (localkey I SAMPLE_WAIT) « Led.clear(); Led. setcursor(@, @); Lcd.print ("current Key:"); led. setcursor(@, 2); ed. print(Localkey)} Documents = LCDKeypad Shield Schematics V1.0 (http://www dfrobot.com/image/data/DFR0009/LCDKeypad%20Shield%20V 1.0%20SCH.pdf) = LCDKeypad Shield Schematics (http://www.dfrobot.com/wiki/images/a/a7/LCDKeypad_Shield_SCH.png) = Shield diagram (http://www shieldlist.org/dfrobot/led) Old libraries for V1 = LCDKeypad (http://www.dfrobot.com/image/data/DFR0009/LCDKeypad.zip) = DFR Key (http://www.dfrobot.comvimage/data/DFR0009/DFR_Key zip) —» Go Shopping Arduino LCD&KeyPad Shield (SKU: DFR0009) (http://www. dfrobot.convindex.php? route=product/product&keyword=DFR0009&category_id-O&description=1&model=1 &product_id=51) Retrieved from "https://www.dfrobot.com/wiki/index.php? title“Arduino_LCD_KeyPad_Shield (SKU:_DFR0009)&oldid-8201" Categories: Product Manual | DFR Series | Shields | LCDs = This page was last modified on 17 January 2014, at 15:34. = This page has been accessed 458,276 times ip shwarw robot camiwikiindex.sb\Aréuina_LCD_KeyPad_ Stile (SKU:_DFRo008) 86

Vous aimerez peut-être aussi