BBC micro:bit
VKey Voltage Keypad

Introduction

The Vkey Voltage Keypad is a keypad made by Sparkfun and costs around £10. That's quite expensive for a keypad but there is a twist. This keypad outputs an analogue voltage that changes depending on which button is pressed. You get 12 extra buttons and only need to use one analogue pin to read them.

Connecting

There are only 3 connections to make here.

micro:bit Circuit

Programming

The first program to write is one to find the voltages for each key. You can get the micro:bit to tell you that with a test program like this,

micro:bit Code

Having to press the A button on the micro:bit makes it easier to press the buttons one at a time and watch the voltages scroll across the screen. Write down the numbers you get for each button, you'll need these later.

Once you have the full list of voltages, you'll be able to finish off the following program,

micro:bit Code

The program, once finished, will display the number of the button pressed on the matrix. Notice that there is an IF nested inside another. The first block is checking that a key is pressed. Anything less than 50 meant that no key was being pressed.

Challenges

  1. You can obviously amend the script to do something different when each button is pressed. If you move the connection to Pin 1, you can play notes on Pin 0 based on which key is pressed.
  2. You could use the keypad as a menu for a series of images, tunes or some other output.
  3. Some form of calculating device would be interesting too.