Bluetooth Bike Audio Remote

by avandermeer in Circuits > Gadgets

3283 Views, 5 Favorites, 0 Comments

Bluetooth Bike Audio Remote

IMAG1271.jpg
WhatsApp Image 2017-09-11 at 21.18.15.jpeg
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!

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)

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.

Design the Circuit

schema.png
52713d5b757b7fc0658b4567.png
rn42.png

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.

Solder the Pieces

2017-09-07 16.09.36.jpg
2017-09-07 16.13.15.jpg
2017-09-07 16.24.21.jpg
2017-09-07 18.13.29.jpg
2017-09-07 18.13.38.jpg

Solder the pieces according to schematics; I love heat shrink tubes, so I used them frequently.

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.

Downloads

Design the Case!

WhatsApp Image 2017-09-11 at 23.03.33 (2).jpeg
WhatsApp Image 2017-09-11 at 23.03.33.jpeg
WhatsApp Image 2017-09-11 at 23.03.34.jpeg
WhatsApp Image 2017-09-11 at 23.03.33 (1).jpeg
WhatsApp Image 2017-09-11 at 23.03.32 (1).jpeg
WhatsApp Image 2017-09-11 at 23.03.32.jpeg

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.

Enjoy the Music!

WhatsApp Image 2017-09-11 at 21.18.14.jpeg