Introduction: Bluetooth Bike Audio Remote
Like me, lots of people drive their bike while enjoying some music from their earbuds. Most of the time the smartphone rests in my pocket, but I regularly take it out to change the song, the volume, or even for pausing the music. Not necessarily a contribution to road safety. Therefore, I decided to make an audio remote control for my bike!
Step 1: Getting the Pieces
1. RN 42 bluetooth module (it supports the HID protocol)
2. Attiny85 or an equivalent small microcontroller + programmer (I used an Arduino Uno)
3. 5 way tactile switch (like this one)
4. Wires and heat shrink tubes
5. Access to a 3d printer
6. A small lithium battery
In case of an Attiny85: two diodes (I used the 1N4148)
Step 2: Short Technical Description
For controlling the music on a smartphone, I decided two use the bluetooth HID protocol, which is used for emulating keyboards and other input devices. I looked up the datasheet of the RN42 bluetooth module and found commands for emulating several media keys, such as volume, next/prev track and play/pause.
The 5 way switch will function as follows:
- up/down: volume
- left/right: previous/next track
- press in middle: play/pause
The RN42 can be controlled via UART. Therefore, I decided to use an Attiny85 as bridge between the button and the RN42.
Step 3: Design the Circuit
The design is quite straightforward; The 5 pins of the 5 way switch are connected to the microcontroller, and the common pin is connected to the ground. I used the internal pull-ups of the Attiny85 (see the arduino code below) for preventing floating values.
However, there was one challenge: while the Attiny85 only has 5 usable pins, 5 pins are required for the switch and 1 pin is required (TX can be ignored) for the RN42 RX. The solution was simple: combine two pins of the switch to simulate an additional input. For this I used two diodes, as you can see in schematic.
Step 4: Solder the Pieces
Solder the pieces according to schematics; I love heat shrink tubes, so I used them frequently.
Step 5: The Code!
See the code attached; I required the TinyDebugSerial library from jscrane: https://github.com/jscrane/TinyDebugSerial
To flash the code to the attiny85, I used an Arduino Uno as ISP programmer. See this instructable.
Step 6: Design the Case!
Of course you can use my stl files; I decide to use a horseshoe formfactor, so it can fit around the handlebar. I added a batterycase at the bottom, which can be easily detached.