Saturday, September 23, 2017

How Fast? Test how fast you are!

How fast? is a project I made for the 2017 Jerusalem Mini Maker Faire.It consists of four different tests:

The Drum Test

Use the sticks to drum as fast as possible. The faster the drumming is, the higher the green bar goes.

The Swipe Test

Swipe your hand (any direction) above the tester as fast as you can. The faster you move your hand, the higher the green bar goes.

The Chase Test

Press the two buttons one after another. The order does not matter, but the first button pressed must be released before the other button is pressed. The faster you hit the buttons, the higher the green bar goes.

The Response Test

Hit the button as fast as you can immediately after the light on the board turns on. The faster your response time to that light, the higher the green bas goes.


All the games share a common overall construction.
The base is made from a piece of thick (~25mm) chipboard, about the size of 30x30cm. In the back side of the board, I milled a rectangular hole, holding a 3D printed ABS box. The box contains an Adafruit Trinket board on which the game software is implemented. 

Beside this common structure, each base board was drilled to milled with features required for each particular test. 
The chase test was the simplest with only two holes for two buttons. I used arcade style buttons which are both robust and give a nice feeling of a game.
The response test is also simple, with a drilled through hole for a button, a drilled through hole for a LED, and a few millimeter deep circular hole that is used to hold a LED cover. The cover was 3D printed from translucence ABS.
The swipe test posed a problem. In order to detect the hand proximity, I used a pair of optical proximity sensors, mounted on a tiny PCB. Unfortunately, the PCB does not have any mounting holes. In order to mount them, I designed and printed mounting accessories, which held the sensor in place while permitting it to be screwed to the base board.

The drum test is made of a round rubber pad (which actually came from an electronic drum system) to which an Adafruit accelerometer sensor board is attached. Interestingly, the hole in the rubber pad in which the board resides looks very much like Adafruit's logo... Finally, the rubber pad was glued to the base board.

All four games are connected to a "Result Bar" - a bar graph showing the result. The design is identical to all four games - a 1M long piece of foam board, to which a common WS2812 LED strip is attached. The bottom area of the board, where the strip is terminated, is covered with another small piece, to hide the solder points. The connection between the two units (the game and the result bar) is made with a Servo Extension Cable, that has exactly three conductors, as requires, and is cheap and easily available.

Full mechanical models can be found on the project's document at OnShape.


The circuits here are quite trivial. As mentioned earlier, I used Adafruit Trinket board. I chose the 5V version, because it easily interfaces the LED strip (WS2812 LEDs) used to show the results.
Trinket is a tiny board, with very few I/O pins available . Pin #1 is used in all circuits to drive the LED strip. Two additional pins are used differently for each specific test for the buttons, LEDs, proximity sensors and accelerometer.

Swipe Test Schematic

Chase Test Schematic

Drum Test Schematic

Response Test Schematic


Overall, the software used in this project is quite simple. The only two pieces of hardware that require software libraries are the WS2812 LEDs and the LIS3DH accelerometer. Both libraries are available in Arduino ecosystem, so chosing that path is very convenient.
Instead of writing directly in the Aruduino IDE, I used PlatformIO. This environment solves two major drawbacks that exist in the original Arduino environment - the IDE and dependency management. 
The IDE used by PlatformIO is Atom, GitHub's extensible text editor. While not being my favorite editor, it is much better than Arduino's editor, with full directory management, GIT interface, code completion and everything else that one would expect from a modern programmer's text editor.
The library dependency management is solved by a kind of manifest file, called platformio.ini that  exists in any PlatformIO project. This file specifies, among others, the libraries required to compile the project. The builder fetches those libraries and with other pieces of information in that file (such as the location of the source files), builds any specified target automatically.
The only serious drawback I found was the fact that the builder does not print, or keep track of the final file size. With Trinket, I've accidentally overwritten the bootloader. This situation is not irreversible, but causes major inconvenience.

The full source code is available in the project's GitHub repository.

No comments:

Post a Comment