Wearable BlueTooth Controller for Switch Adapted Toys
by r570sv in Circuits > Arduino
1018 Views, 5 Favorites, 0 Comments
Wearable BlueTooth Controller for Switch Adapted Toys
We have a family member who has Rett syndrome and has difficulty using her hands. She has switch adapted toys that are activated with a large button you push or a foam ball that you squeeze. She has some trouble doing this but she's very good at clapping. I decided to see if I could make something she could wear on the back of her hand and when she claps it will activate the toy.
I wanted the connection to be wireless because I figured with all the clapping, a cord from the wearable would get tangled up with the toy.
Supplies
I knew I would be using Arduinos for the solution so I went to my go-to site adafruit.com They have every Arduino (and pi) gadget you can think of and a lot of gadgets you haven't even figured out you need yet.
For this Instructable, I used -
Adafruit ItsyBitsy nRF52840 Express-Bluetooth LE
Adafruit Lilon/LiPoly Backpack Add-On for the Pro Trinket/ItsyBitsy
Adafruit Triple-Axis Accelerometer
Adafruit LP 3.7v 105mAh battery
1 Channel Relay Module With Optocoupler Isolation
Miscellaneous wires, switches
Potentiometers for adjusting runtime and delay
Battery holder for toy controller's power
Access to a eBay laser cutter and wood to make the enclosures
soldering iron, solder, super glue, misc tools
Problem to Solve
Ok to re-iterate what I'm building
A device a child can wear on the back of their hand that can control a switch adapted toy by clapping their hands together.
This is comprised of two components.
A wearable device that can activate the toy when a child's hands are clapped together.
A receiver that receives message from the wearable device and activates the switch adapted toy. The receiver needs to be able to set a duration the toy is active as well as a delay between activations.
The wearable device needs to be small, self contained (have a battery), be able to be turned on and off and be easily rechargeable. It also needs to be able to detect motion - hands clapping. (That's a lot of functionality for something so small - at least for me to build).
At first for the remote control I wanted to see if I could leverage whatever is in the low cost switch/keychain remote control you use for turning on and off Christmas lights and other gadgets. After a quick search I didn't find what I wanted and wasn't in the mood to buy new devices and try to hack them.
From the get-go I going to use Arduinos for the solution.
Looking at the Adafruit site I came across the ItsyBitsy nRF52840 Express-Bluetooth LE that has BLE ALREADY BUILT IN! This was a no-brainer in my book because I didn't have to add a separate BLE board later or some other wireless communication solution I would have to hunt around for.
What the Code Does
So I've did a lot of Arduino work in the past (you can check my other Instrtuctables) and using BLE in a Arduino is some complex stuff as far as Arduino's go. The FANTASTIC news is Adafruit provides AMAZING samples/libraries/forums that made using BLE pretty easy. I basically just cloned the sender/receiver examples and added my new work to it.
The Wearable does the following -
Starts up and waits to find a connection to the controller via BLE (All of this code is in the sample)
When a connection is made it sits in the Arduinos loop() routine reading the values from the 3 axis Accelerometer. Each read I take 10 samples for each axis with a brief delay and average them together.
I compare those values (x,y,z axis) to the previous read values and if its changed enough - doesn't matter what axis it is, its sends a one character message to the controller via BLE.
It repeats the above.
If the connection breaks, the Arduino code is smart enough to jump out of the loop and starts looking for the connection again.
The Controller does the following -
Starts up and waits to find a connection to the controller (again, of this code is in the Adafruit sample)
When the connection is made sits in the loop() routine waiting on a readPacket() from the bluetooth library.
When a message is received it checks to see if the data (a single character) is the correct value.
If correct, it will read the values from the motor run potentiometer and the delay potentiometer.
It will turn on the pin that controls the relay, pulling it in so the toy will start running for the proper time.
It will turn off the pin controlling the relay and delay the amount of time read from the delay potentiometer
after the delay it will do another readPacket() to flush the buffer and return to the top of the loop and wait for another read. I flush the buffer just in case another message was sent so that the toy won't immediately run again.
Why check the single character on the read when the controller only does one thing? Well I envisioned that there may be a toy that can do multiple things - think of a toy car. forward, backward turn left, turn right and if I was to pay attention to which axis moves X,Y,Z in the wearable I could wireless control a toy car - or any other device that requires multiple inputs.
Breadboarding the Wearable and Controller
From a coding point of view, getting some sense of what the BLE code was doing took a little time figuring out how to get them to connect. Since there were two Arduinos and two different sketches working. A lot of back and forth with two different sketches open and trying different things to get them to run smoothly connect to each other, reconnect, etc..
Once that was done, adding a relay and reading from two pots is pretty straight forward Arduino coding. The 3 axis Accelerometer took a little work - trying to shake it enough to get it to change value and figuring out what values to use as well as taking samples and averaging them. When it was on the bread board also made it tough to jiggle it around.
Once it was breadboarded and working, I could move to the next phase - figuring out how to get them into a box so that they could be used. Which involves moving them off of the breadboard.
Building the Containers
Since I've spent a lot of time using the generic 'eBay laser cutter' it was a no-brainer that I would use a combination of Acrylic sheet and wood to build the containers. I won't go into that in this Instructable as there are lots of articles, YouTube videos, etc. on how to use this tool.
The controller was basically a box holding the two pots, the Arduino board and the batteries to power the Arduino. I had the luxury of making it as large as I wanted to make everything fit.
The wearable was a challenge. After breadboarding it I had to basically solder wires to all the pieces and make it small enough for someone to wear. It was a challenge getting the battery charger board, the Accelerometer and the battery all wired together with the Arduino in the middle - and stay together and not break a wire.
The Adafruit products work well together - for charging the battery the pieces are smart enough that I can use the Arduino's USB port for charging. The Arduino is smart enough to know that the battery charger is connected so it lets it borrow the USB port to get the battery charged. An On/Off switch was added to the front so it can be turned on and off. I managed to fit the Accelerometer and wires on as well. I left the cover clear so you can see the blue LED on the board that tells you when the BLE connection is made. The Adafruit code is so tight that I can turn either on first and they connect, or turn one off and on and they will reconnect.
Using It!
Having the person that built it, test is only goes so far. You need some real world user experience. I tuned the wearable code to the point that it didn't take much movement/quick movement to send the signal. I hobbled up a Velcro strap to hold it on to the users wrist. If you check the YouTube video out you can see it in action.
Next Steps
I would like to build a 3d printed enclosure for the wearable as well as a more comfortable way to wear it and it doesn't look like a box strapped to someone hand. Also I need to try out some other switch adapted toys to make sure it work.