|
Autodesk Fusion 360Autodesk
|
|
|
KiCADKicad
|
Wireless Bike Media Controller
I wanted an easy way to control my music while biking without having to look at my phone. This project solves that issue. This wireless device features a rotary encoder for volume and a mute button, plus three keys for previous track, play/pause, and next track. It also has a LiPo battery so no cables are needed. Just attach the bottom plate to the handlebar mount which fits your handlebars and you won't have to worry about looking down to switch songs!
Controls
- Left Button: Previous Track
- Center Button: Play/Pause
- Right Button: Next Track
- Knob CW: Volume Down
- Knob CCW: Volume Up
- Knob Button: Mute/Unmute
Hardware
- Seeed Studio XIAO ESP32C3
- 3x MX Switches
- 5x 10k Ohm Resistors
- Rotary Encoder
- 3.7v LiPo Battery
- 4x M3 x 6mm Screws
- 4x M3 heat set inserts
#include <BleKeyboard.h>
#include <RotaryEncoder.h>
const int button1Pin = 5;
const int button2Pin = 6;
const int button3Pin = 7;
const int encoderAPin = 4;
const int encoderBPin = 3;
const int encoderSwitchPin = 2;
bool button1Pressed = false;
bool button2Pressed = false;
bool button3Pressed = false;
bool encoderSwitchPressed = false;
BleKeyboard bleKeyboard;
RotaryEncoder encoder(encoderAPin, encoderBPin, RotaryEncoder::LatchMode::TWO03);
void setup() {
Serial.begin(9600);
pinMode(button1Pin, INPUT_PULLUP);
pinMode(button2Pin, INPUT_PULLUP);
pinMode(button3Pin, INPUT_PULLUP);
pinMode(encoderAPin, INPUT_PULLUP);
pinMode(encoderBPin, INPUT_PULLUP);
pinMode(encoderSwitchPin, INPUT_PULLUP);
bleKeyboard.begin();
}
void loop() {
// Check button inputs
if (digitalRead(button1Pin) == LOW && !button1Pressed) {
button1Pressed = true;
Serial.write("Prev\n");
bleKeyboard.press(KEY_MEDIA_PREVIOUS_TRACK);
} else if (digitalRead(button1Pin) == HIGH && button1Pressed) {
button1Pressed = false;
bleKeyboard.release(KEY_MEDIA_PREVIOUS_TRACK);
}
if (digitalRead(button2Pin) == LOW && !button2Pressed) {
button2Pressed = true;
Serial.write("Play/Pause\n");
bleKeyboard.press(KEY_MEDIA_PLAY_PAUSE);
} else if (digitalRead(button2Pin) == HIGH && button2Pressed) {
button2Pressed = false;
bleKeyboard.release(KEY_MEDIA_PLAY_PAUSE);
}
if (digitalRead(button3Pin) == LOW && !button3Pressed) {
button3Pressed = true;
Serial.write("Next\n");
bleKeyboard.press(KEY_MEDIA_NEXT_TRACK);
} else if (digitalRead(button3Pin) == HIGH && button3Pressed) {
button3Pressed = false;
bleKeyboard.release(KEY_MEDIA_NEXT_TRACK);
}
if (digitalRead(encoderSwitchPin) == LOW && !encoderSwitchPressed) {
encoderSwitchPressed = true;
Serial.write("Mute\n");
bleKeyboard.press(KEY_MEDIA_MUTE);
} else if (digitalRead(encoderSwitchPin) == HIGH && encoderSwitchPressed) {
encoderSwitchPressed = false;
bleKeyboard.release(KEY_MEDIA_MUTE);
}
// Check encoder rotation
static int pos = 0;
encoder.tick();
int newPos = encoder.getPosition();
if (pos != newPos) {
int dir = (-1) * (int)(encoder.getDirection());
if (dir > 0) {
bleKeyboard.press(KEY_MEDIA_VOLUME_UP);
delay(200); // Increase this delay for larger moves
bleKeyboard.release(KEY_MEDIA_VOLUME_UP);
Serial.write("Volume Up\n");
} else {
bleKeyboard.press(KEY_MEDIA_VOLUME_DOWN);
delay(200); // Increase this delay for larger moves
bleKeyboard.release(KEY_MEDIA_VOLUME_DOWN);
Serial.write("Volume Down\n");
}
pos = newPos;
}
}
Wireless Bike Media Controller
Project images are for reference only. Actual production is based on the manufacturing files on the project page.
Please review the designer's notes (e.g., PCB thickness) and select the appropriate options.
PCBWay is not responsible
for issues caused by unsuitable parameter selections.
For more important ordering information, please refer to
Read More
Raspberry Pi 5 7 Inch Touch Screen IPS 1024x600 HD LCD HDMI-compatible Display for RPI 4B 3B+ OPI 5 AIDA64 PC Secondary Screen(Without Speaker)
BUY NOW- Comments(2)
- Likes(2)
-
Bob Bob Shepard
Aug 11,2024
-
Engineer
May 17,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Engineer
-
Programmable Mist Maker - XIAO / QT PY Extension
1224 2 1 -
RadioHAT - Raspberry Pi radio development platform
1029 0 2 -
QWIIC-VL53L4CD Time-of-Flight Distance Sensor Module
1248 0 1 -
-
-
-
ARPS-2 – Arduino-Compatible Robot Project Shield for Arduino UNO
3441 0 6 -
-
A Compact Charging Breakout Board For Waveshare ESP32-C3
4076 3 8 -
AI-driven LoRa & LLM-enabled Kiosk & Food Delivery System
4471 2 2







