/*************************************************************
*****************
VKey_demo_main.ino
VKeyVoltageKeypaddecodingdemo
ByByronJacquot@@SparkFunElectronics
February4,2014
https://github.com/sparkfun/VKey_Voltage_Keypad
ThisdemonstratesinterfacingtheSparkFunVKeyvoltagekeypa
dusing
theVKeyArduinolibrary.
TheVKeyhasanarrayof12pushbuttons,eachproducingauni
queanalog
voltagewhenpushed.Amicro
controllercanreadthevoltag
e,anddetermine
whichkeyhasbeenpressed.TheVKeylibrarykeepstrackof
theanalogpin
connection,keystatus,andvoltagecalibrationdetails.
TheVKeywasconnectedtotheArduinoasfollows:
VKeyGND>ArduinoGND
VKeyVout>Arduinoanalogin
putA1
VKeyV+>ArduinoVCC
Tousethelibrary,instantiateaVKeyobjectandperiodicall
ycheckforinput
usingthecheckKeys()function.
Resources:
noadditionallibraryrequirements
Developmentenvironmentspecifics:
DevelopedonArduinoIDE1.0.5
Testedona5VRedboardand3.3VProMini
Thiscodeisbeerware;ifyouseeme(oranyotherSpark
Fune
mployee)atthe
local,andyou'vefoundourcodehelpful,pleasebuyusarou
nd!
Distributedasis;nowarrantyisgiven.
**************************************************************
****************/
#include<VKey.h>
//GlobaldeclarationoftheVKeyclass
//Initializedwithanalogpinnumberandsupplyvoltage
VKeykeypad(A1,VKey::FIVE);
void
setup()
{
//Initializeserialportfortextoutput
Serial.begin(9600);
Serial.println("WelcometoVKeyexample");
//NoVKeyspecificinitializationrequired.
}
void loop()
{
VKey::eKeynumk;//Variabletoreceivethekeyindication
Page 6 of 8