GitHub site: https://github.com/hardwaremonkey/microbit_flex
How can we use a small sideways hand motion or a small finger movement to act as a switch for switchable software using off the shelf hardware?
We can use an off the shelf flex sensor connected to a BBC micro:bit which has been configured to act as a switch to control switchable software. For an explanation of what switchable software is and how we can use a BBC microbit to act as a switch to interact with it, please see my blog post here.
A photo showing preliminary testing at at Beaumont College, Lancaster, UK is shown below. The flex sensor is being flexed against Fil's wrist. The pattern on the red LEDs on the microbit shows that the bend in the flex sensor has been detected and that a switch signal was sent. The green dot on the software on the laptop screen shows that the switch is detected by the laptop. This switch emulates a keyboard keystroke. This allows communication software to be operated by somebody who is unable to use a regular keyboard or other interfaces.
This project is still being developed and tested. The preliminary design is presented below. Project code can be downloaded from the GitHub site linked at the top of this page.
Please see a short video below showing the first stage of the prototype, where bending a flex sensor attached to a microbit triggers an LED to flash.
The need for this project came from Beaumont College where a student was identified who is unable to use standard switch hardware, such as buttons, but is capable of making an intentional small sideways hand movement. Initially, we thought of using a fancy armband that could measures muscle activation to detect when the student made the hand motion. I had an idea for a potentially simpler solution, which would avoid The World of Pain of writing software for the armband to reliably detect a single small gesture. There is another student who has limited finger movement and is unable to operate tactile switches due to the resistance they have. Potentially she may be able to bend a flex sensor.
The device we developed uses a flex sensor which is bent when the student moves his hand against it. Please see the photo below for a possible way of implementing this.
This bend changes the resistance of the flex sensor. The resistance increases as it is flexed in one direction - not so much when it is bent in the other direction. I bought two different flex sensors - one is about 100mm long and a shorter one is about 60mm long. The longer one may be better for detecting a hand movement, the shorter one could be used for a single finger movement. The photo below shows the 100mm flex sensor worn using a £3 wrist support band from eBay, arranged so that the flex sensor will detect a sideways hand movement.
The change in resistance of the flex sensor as it bends is detected with a BBC microbit that is running some code I wrote. The microbit slots into a Kitronik edge connector. The flex sensor and a cable that enables the system to act as a switch for switchable devices are connected to this edge connector. The flex sensor is in series with a resistor on the Kitronik edge connector board. This creates a resistor bridge, so that the change in resistance of the flex sensor as it bends can be measured. The value of the resistor on the Kitronik edge connector is different for the two lengths of flex sensor. I soldered 0.1" sockets onto the Kitronik edge connector for the flex sensor cable and the resistor to plug into easily. I blanked off any unused sockets to help ensure that the flex sensor cable and resistor can only be plugged in correctly.
4.5" flex sensor (12.8K Ohm resistance with no flex): 27K Ohm resistor on the Kitronik edge connector.
2.5" flex sensor (29K Ohm resistance with no flex): 67K Ohm resistor on the Kitronik edge connector.
These resistors soldered onto their 'plug and play' mountings can be seen in the photo below.
I soldered the two different resistors to 0.1" header pins so that they can easily be swapped on the 0.1" sockets I soldered onto the Kitronik edge connector.
The code running on the microbit can be downloaded from my Github site. The link for this is towards the start of this page. To enable the microbit to act as a switch, a signal is sent to an attached 3.5mm jack plug.
Details on how to make and connect this 3.5mm jack plug cable can be found here.
A switch trigger is sent when the flex sensor is bent beyond an adjustable threshold. The threshold for how much the flex sensor needs to be bent before a trigger is sent is set using the two buttons on the microbit. Pressing the B button increases how much the sensor must be flexed before it triggers. Pressing the A button decreases how much the sensor must be flexed - so this increases the sensitivity of the device to detect a smaller hand motion.
The microbit has a 5x5 array of LEDs on the front. The faint LEDs indicate the trigger level. The bright LEDs indicate the amount of flex detected. When the number of bright LEDs exceeds the number of faint LEDs, a trigger work is sent from the microbit to the device it is connected to.
There is a version of the code that goes on the microbit on my Github site that instead of sending a trigger using a 3.5mm switch cable, sends a text signal to a laptop through the USB cable that can be used to connect the microbit to a laptop. There is a Python file on my Github site that can be set running on the laptop. This listens out for this text signal from the microbit and then flashes an attached USB LED dongle. You could modify this Python file to do something else.
For this project, I used the microbit block editor to develop the software which runs on the microbit. The .hex file I created can be downloaded from my Github site, the link is towards at the top of this page. As the microbit is given to all 11-12 year olds in the UK to learn how to program using this block editor, if you have any problems, please ask your nearest 11-12 year old for help. They will probably improve my code as well.
So how do we test cutting edge assistive technology? With a switch activated toy dog of course...
One final Top Tip is to replace the AAA battery pack that comes with the microbit with one that has a power switch. These are about £4 + £0.75 postage from eBay. The title for the battery box with a switch that I bought is 'Switched battery power box for BBC Micro:Bit 2 x AAA'.
The hand wave device is being tested at Beaumont College. Hopefully it will be of benefit and enable some of the students who currently cannot access communication software to be able to access the software.
I developed a version with two microbits. One microbit is worn by the student. This is attached to the flex sensor. When a bend is detected, a signal is sent using the microbit's excellent radio to a second microbit, which could be some distance away. The second microbit then acts to send a switch command. The remote microbit can be used to adjust the sensitivity of the microbit attached to the flex sensor, to avoid invading the student's personal space.
Please get in touch if you want further details of this project. Please note that as I spend long periods working in remote areas offshore, if you don't hear back from me, it's not that I'm ignoring you, it's that I am one of the few remaining people on the planet who can go for some days without internet access.