Skip to content

Control system volume using a Raspberry Pi Zero (emulating a multimedia/CCB keyboard) πŸ’»πŸ”Š

Notifications You must be signed in to change notification settings

benjamingwynn/usb-volume-control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

What is this?

Turn your Raspberry Pi (or other Linux device capable of being a USB Gadget) to a multimedia keyboard with volume controls!

It uses a daemon to control what actions should be taken over USB depending on GPIO inputs, by default volumeUpPin is GPIO input 20 and volumeDownPin is 21. If you hold both volume up and down together it'll play/pause media.

This is all easily configurable inside the daemon.

Raspberry Pi Zero wiring diagram

Easy install guide for Raspberry Pi Zero (W)

  1. Flash Raspbian onto the SD card of the Zero with the Raspberry Pi Imager
    • IMPORTANT: make sure to add an SSH login and wifi credentials to access the device
  2. Plug the raspberry pi into your computer using the data microUSB port (the second one from the edge)
  3. SSH into your pi and clone the repo with git clone https://github.com/benjamingwynn/usb-volume-control
  4. cd into usb-volume-control and run the ./rpi-zero-install.sh script

Manual installation

  1. Prepare your system for use as a USB gadget
    • load dwc2 and libcomposite kernel modules on boot
    • add dtoverlay=dwc2 to your Pi's boot config.txt if using a Raspberry Pi
  2. Install the mkdevice.sh script somewhere, it needs to be ran on root at startup to create the keyboard USB device.
  3. Run daemon/daemon.mjs using node.js to monitor GPIO pins and emit events to the emulated USB keyboard.

References/further reading

The following resources were very helpful in putting this all together:

USB HID/USB Gadget/Raspberry Pi:

Multimedia/CBB keys:

GPIO:

About

Control system volume using a Raspberry Pi Zero (emulating a multimedia/CCB keyboard) πŸ’»πŸ”Š

Topics

Resources

Stars

Watchers

Forks