PRT-12080

Attaching the tact switches
Depending on how the board is to be mounted, different headers can be
soldered to the board.
If the overall depth of the assembly is a concern, you can use a right angle
header on the same side of the board as the tact switches.
Right angle header on top of board
If clearance past the edge of the board is a concern, you can use a straight
header soldered to the side opposite the switches.
Straight header on back of board
And of course, you could always solder wires directly to the board in place
of the header.
Connecting The VKey To An Arduino
Basic hookup to an Arduino
It takes three wires to connect the VKey to an Arduino.
(VKey Arduino)
•V+ 5V
Vout A1 (or any other analog pin)
GND GND
Arduino Library
Page 4 of 8
To make interfacing the VKey as simple as possible, we’ve written an
Arduino library and example sketch. If you need a refresher on how to
install an Arduino library, please see our library tutorial.
The VKey library provides an object that interfaces with a VKey keypad. In
a typical application, this class is instantiated as a global object before the
setup() function. In the VKey object declaration, you need to select the
appropriate analog input pin, and set the power indication to the proper
voltage, either
THREE (actually shorthand for the more common 3.3V) or
FIVE .
It is possible to attach several VKeys, each on it’s own analog input pin, by
declaring multiple VKey objects to watch the corresponding analog pin
numbers.
The VKey status is queried using the function
bool CheckKeys(eKeynum & k);
The function will always return an indication of the current button in
reference parameter k, or
NONE in the case that no buttons are pressed.
The function also returns a boolean indication of whether the key has
changed since the last time it was queried – a form of edge detection. Many
applications will only care about handling the key number when it updates,
and don’t need to process the input when it is unchanging.
The next page will show us a quick sample sketch that uses the VKey
library.
Example Code
Once you have installed the library, open the Arduino IDE, and paste the
following into the sketch:
Page 5 of 8
/*************************************************************
*****************
VKey_demo_main.ino
VKeyVoltageKeypaddecodingdemo
ByByronJacquot@@SparkFunElectronics
February4,2014
https://github.com/sparkfun/VKey_Voltage_Keypad
ThisdemonstratesinterfacingtheSparkFunVKeyvoltagekeypa
dusing
theVKeyArduinolibrary.
TheVKeyhasanarrayof12pushbuttons,eachproducingauni
queanalog
voltagewhenpushed.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

PRT-12080

Mfr. #:
Manufacturer:
SparkFun
Description:
Daughter Cards & OEM Boards Vkey Voltage Keypad Voltage Keypad
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet