11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler5.32. INKEYSyntax :Overview :Operators :Variable = INKEYScan a keypad and place the returned value into variableVariable is a user defined variableExample :DIM Var as BYTEVar=INKEYDELAYMS 50PRINT @Var,” “‘ Scan the keypad‘ Debounce by waiting 50ms‘ Display the result on the LCDNotes :INKEY will return a value between 0 and 16. If no key is pressed, thevalue returned is 16.Using a LOOKUP command, the returned values can be re-arrangedto correspond with the legends printed on the keypad: -Var = INKEYKEY = LOOKUP Var, [255,1,4,7,”*”,2,5,8,0,3,6,9,”#”,0,0,0]The above example is only a demonstration, the values inside theLOOKUP command will need to be re-arranged for the type of keypadused, and it’s connection configuration.Declare :DECLARE KEYPAD_PORT PORTAssigns the Port that the keypad is attached to.The keypad routine requires pull-up resistors, therefore, the best Portfor this device is PortB, which comes equipped with internal pull-ups.If the DECLARE is not used in the program, then PortB is the defaultPort.+5 VoltsC110uf0vR14.7kC24MHz0.1ufCrystal16C322pf415C422pf14VDDRB7MCLR RB6RB5RB4RB3OSC1 RB2RB1RB0PIC16F84RA4OSC2 RA3RA2RA1RA0VSS51312111098763211817R2-R54701 2 34 5 67 8 9*0 #COLUMNSROWSThe above diagram illustrates a typical connection of a 12-button keypadto a PIC16F84. If a 16-button type is used, then COLUMN 4 willconnect to PortB.7 (RB7).69Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!