We have been thinking of building a more physical game controller to use it with Scratch or any other Blockly implementation. The overall idea is that the footpad works as a keyboard emulator so it easy to integrate with Scratch. This project is just an initial feasibility study using an Arduino-Uno rather than the Arduino-Leonardo we will use in the future. The Arduino-Leonardo can become a keyboard emulator while the Arduino-Uno can not do this,
PrincipleMechanically it is just two squares of sturdy plywood with a pivot point in the middle of the square to make the whole board wobble. In principle, not more than two corners should be pressed together at the same time.
Electronically we use piezoelectric elements to measure the pressure which we convert to a simple yes or no for each corner that is pressed. So we get four values.
The piezo elements here are used to detect pressure. Their principle is explained in detail here. When they are compressed they will release a voltage that can go up to 20 volts, However, the power/current they can release is limited. Never the less they could damage the Analog-Digital Converters ports of the Arduino. A resistor of 1 Mega Ohm in Parallel reduces this risk. There is more elaborate circuitry that eliminates such risk but so far a simple resistor is cheap easy and proves to work very well.
Hardware assemblyTo keep the top part of the plywood on the bottom one we will use L profiles which we cut to hold both parts together. I made one larger to guide cables through as shown below.
They should be mounted as shown below with screws to the board.
Below the screws I used, flat embedded once for the bottom and rounded ones for the sides. The sizes were those that I had and fitted the building of the board.
Mark the places where you want to drill prior to drilling.
All the electronics will be mounted on the upper plate but we need a cut-out to allow space for the Arduino µ-processor board as shown below.
Below is shown how the two parts fit together.
Notice the resistor mounted in parallel with the piezo-crystal below. The value is around 1 Mega Ohm with 1/4W or even less is required. The wiring is shown on Figure 2.
Notice also the screw in the middle of the board to make the board pivot. There is such a screw on the other board. Some washers are probably required to get a suitable height for the pivot point.
Once all is connected add some foam between the piezo and the bottom board. I glued it all to the bottom of the upper board as you can see below.
Above you see a view of the bottom view of the top board (left-bottom) and the top of the bottom board (right top corner).
I used some candle wax at the areas where there is friction between the aluminum and the wood to reduce the friction.
Below is a view from the bottom where the Arduino is visible including some patches to protect the floor.
This is not the firmware for the pad yet but just a simple code to test the functioning of the pad. We added a very simple running game to explore the pad which is the default setting in the attached code.
Pre-compiler information
// Threshold levels with higher up and lower down threshold "Schmitt-trigger" approach
#define ThresholdUp 500 // value becomes high if reading becomes equal or higher than this value
#define ThresholdLow 50 // value becomes low if reading becomes lower than this value
The Arduino-NO has a 10-bit ADC allowing values from 0 to 1023. When the signal is low or O it will only go to high or one once the value is above a value of 500 which is roughly equivalent to 2.5 volts. The signal will remain high until the signal drops under a value of 50 or 0.25 volts. This simulates the behavior of a Schmitt trigger making the readings more reliable.
// Code inclusion excludion settings
#define Debug 0 // to test the code
#define Logic 0 // to have the logic printed out, best when not the running game counter
#define Game 1 // running game
There are three settings. One is 'Debug' for debugging which was left in the code as it might help to understand the code. 'Logic' is the first attempt just to send the sensor data as zeros and ones as shown below. Only a change in state is sent out as can be seen below. In the left column are the four current values and in the right column the 4 former (old values).
0, 0, 0, 0, || 0, 1, 0, 0
1, 0, 0, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 1, 0, 0, 0
0, 0, 1, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 0, 0, 1, 0
1, 0, 0, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 1, 0, 0, 0
0, 1, 0, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 0, 1, 0, 0
1, 0, 0, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 1, 0, 0, 0
0, 0, 1, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 0, 0, 1, 0
1, 0, 0, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 1, 0, 0, 0
0, 1, 0, 0, || 0, 0, 0, 0
0, 0, 0, 0, || 0, 1, 0, 0
In the 'Game' setting the board will ask how long you want to run. Once ready to record one wants to push and release the left sensor and consequently the same with the right sensor which will be counted as on step. The information as shown in the serial monitor is shown below.
Give a one digit number of minutes you want to exercise: 4
Your chosen exercise time is 4 minutes or 43392 microseconds.
We are ready to record your race ;-)
Start running!
1
2
3
4
5
6
7
8
9
You did it !
You have done 8 steps. Well done!
You had around 2 steps per minute!
The rest, we hope, is well documented in the code itself.
Future development
- Make a python game in which the pad can be used.
- Make another pad but this time with an Arduino Leonardo so it can work as a keyboard wedge. This would allow use with for example Scratch.
- Connect the above (UNO( pad over serial communication with the Leonardo so two pad can be used in the same game through the Leonardo
- Write a python program that runs video a the speed of the pad so people get a feeling that they are running outside.
Comments