/*CheckKeyswillalwaysreturnthecurrentkeyinparamet
erk.
Thebooleanreturnvalueindicateswhetherthatvaluei
sdifferentthan
thepreviousvalue.
*/
if(keypad.checkKeys(k))
{
//Onlyprintwhenvaluehaschanged
Serial.print("Gotkey:");
Serial.println(k);
}
//Theresponsivenessofthekeypaddependsonhowfrequentl
yitischecked.
//50millisecondsseemstobeareasonablepollinterv
al.
delay(50);
}
Build and upload the sketch. Then open a serial terminal, and observe the
output while pressing buttons.
The Arduino recognizes keys based on the voltage produced by the VKey
The Arduino will print notifications as buttons are pressed and released. A
key number of 0 indicates that no keys are currently pressed.
If the Arduino isn’t properly tracking the key numbers, double-check that the
VKey object was declared with the proper analog pin and supply voltage
parameters. Also doublecheck that you’ve got the latest code from the
Github repository.
Resources And Going Further
The VKey is a great way to add up to 12 buttons to a project, while still
leaving many I/O pins for other tasks.
The schematics, PCB artwork and source code for the VKey are all found
on it’s Github page. For a deeper look at the internals of the VKey, check
the documents directory found there. You’ll find a more detailed theory of
operations document, with supporting SPICE simulations and
spreadsheets.
• Github Repository
Modifications
There are a number of possible alterations that can be made to the VKey,
to tailor it to a specific application.
Different Switches
The VKey comes with 12 PTH pushbutton switches, but can support nearly
any normally-open SPST switch, such as arcade buttons or microswitches.
Page 7 of 8