One of the more advanced features of the Circuit Playground is its ability to emulate a USB keyboard and mouse. To do this, we use the Arduino Mouse and Keyboard libraries.
The following sketch uses these libraries to emulate a USB keyboard and mouse and send key and mouse events when the pads are touched.
If this sounds familiar that's because this is essentially what a Makey Makey does. The default key mapping in the sketch provided above is similar to the original Makey Makey.
- PAD #3: Left Arrow
- PAD #2: Up Arrow
- PAD #0: Down Arrow
- PAD #1: Right Arrow
- PAD #12: Space Bar
- PAD #6: Left Mouse Button Click
- PAD #9: Middle Mouse Button Click
- PAD #10: Right Mouse Button Click
We can use alligator clips and some paper to create a cheat sheet for the key mapping. On a 6"x4" index card or other piece of paper, draw something similar to the picture below.
Now attach the alligator clips to the edge of the paper and the Circuit Playground as shown below.
To send the key press or mouse button click, touch the associated alligator clip.
Since there is a danger of flooding your computer with too many key presses or mouse clicks, the slide switch on the Circuit Playground is used to turn the keyboard/mouse emulation on and off. With the slide switch to the left (+), the emulator is active and the red LED will come on. The Circuit Playground will send key and mouse events with every capacitive touch. To turn the emulator off, set the slide switch to the right (-) position.
With this sketch loaded and running on the Circuit Playground, turn on the emulator using the slide switch. Then try out these Makey Makey apps: