Arduino Media Keys

Arduino Media Keys

Arduino Media Keys

In this project, an Arduino Micro is used as a USB-HID (Human Interface Device). The same standard is used for computer devices that take input from humans and/or gives output to humans, such as a computer keyboard, mouse or joystick.

Publication : 09 nov 2018

3D Model



In this project, an Arduino Micro is used as a USB-HID (Human Interface Device). The same standard is used for computer devices that take input from humans and/or gives output to humans, such as a computer keyboard, mouse or joystick. More precisely, the device using the standard needs to identify itself using one of the available groups of devices, e.g. Generic Desktop, Simulation Control, VR Control, Game Control, Keyboard, etc. Groups with their corresponding functions and control codes can be found here:

In this project we will use the group Consumer, which enables us to control the computers media player functions (e.g. Play/Pause, Next song, etc.) and global volume control.

The finished device can be used on Windows, Linux, Mac and Android systems or any other device that supports USB-HID.

(Disclaimer: for now the device was tested only on a Mac Pro.)


  • Arduino Micro
  • 6 push buttons
  • USB cable
  • a box to hold the buttons (This section will be added later)


In the below example you can see how to connect a simple push button to an Arduino pin.

push button schematic

In this case one pin of the push button is connected to the GND pin of the Arduino via a black wire. The second pin of the push button is connected to the digital pin number 2 of the Arduino via an orange wire. Programmatically, we will define the digital pins as digital inputs with the enabled internal pull-up resistor. Therefore the pins are normally HIGH, except when the button is pressed, (connected to the ground) and the digital input is read as LOW.

The 6 push button for this project will be connected to the Arduino in the same way, each to a different digital pin on the Arduino.

The button connections to the digital pins are as follows:

  • Play = pin 2
  • Forward = pin 3
  • Back = pin 4
  • Volume Up = pin 5
  • Volume Down = pin 6
  • Volume Mute = pin 7

The GND pins can be daisy chained.

Arduino Sketch

HID Library

  • Menu→Sketch→Include Library→Manage Libraries
  • Search: "HID"
  • Select: HID-Project by NicoHood Version 2.5.0 or newer
  • Install



Arduino Media Keys
Version 1.0

Tomo Murovec
UBO Open Factory
Brest, France

HID-Project by NicoHood Version 2.5.0 or above
- can be found in Arduino Lirary Manager
- or:

// include the HID library
#include "HID-Project.h"

// definitions for each pin used
const int pinLed = LED_BUILTIN;
const int playButton = 2;
const int fwdButton = 3;
const int backButton = 4;
const int volUpButton = 5;
const int volDwnButton = 6;
const int muteButton = 7;

void setup() {

// define the pin mode for each pin used
pinMode(pinLed, OUTPUT);
pinMode(playButton, INPUT_PULLUP);
pinMode(fwdButton, INPUT_PULLUP);
pinMode(backButton, INPUT_PULLUP);
pinMode(volUpButton, INPUT_PULLUP);
pinMode(volDwnButton, INPUT_PULLUP);
pinMode(muteButton, INPUT_PULLUP);

// begin HID connection

void loop() {

// if the play button is pressed
if (!digitalRead(playButton)) {
digitalWrite(pinLed, HIGH); // turn on LED
Consumer.write(MEDIA_PLAY_PAUSE); // send HID command
delay(500); // wait
digitalWrite(pinLed, LOW); // turn off LED

// all the buttons follow the same pattern ...

if (!digitalRead(fwdButton)) {
digitalWrite(pinLed, HIGH);
digitalWrite(pinLed, LOW);

if (!digitalRead(backButton)) {
digitalWrite(pinLed, HIGH);
digitalWrite(pinLed, LOW);

if (!digitalRead(volUpButton)) {
digitalWrite(pinLed, HIGH);
digitalWrite(pinLed, LOW);

if (!digitalRead(volDwnButton)) {
digitalWrite(pinLed, HIGH);
digitalWrite(pinLed, LOW);

if (!digitalRead(muteButton)) {
digitalWrite(pinLed, HIGH);
digitalWrite(pinLed, LOW);


Some interesting links:


Example: Volume UP botton

Taken from the HID-Project arduino library.

Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.

Consumer example
Press a button to play/pause music player

You may also use SingleConsumer to use a single report.

See HID Project documentation for more Consumer keys.

#include "HID-Project.h"

const int pinLed = LED_BUILTIN;
const int pinButton = 2;

void setup() {
pinMode(pinLed, OUTPUT);
pinMode(pinButton, INPUT_PULLUP);

// Sends a clean report to the host. This is important on any Arduino type.

void loop() {
if (!digitalRead(pinButton)) {
digitalWrite(pinLed, HIGH);

// See HID Project documentation for more Consumer keys

// Simple debounce
digitalWrite(pinLed, LOW);

Some media key definitions from the HID-Project arduino library.

Additional commands can be easily added using the same pattern (#define) and HID codes found in the next section.

// Media key definitions, see official USB docs for more
#define MEDIA_REWIND 0xB4
#define MEDIA_NEXT 0xB5
#define MEDIA_STOP 0xB7

#define MEDIA_VOLUME_UP 0xE9



Consumer HID codes


12 Consumer
0x00 Unassigned
0x01 Consumer Control
0x02 Numeric Key Pad
0x03 Programmable Buttons
0x20 +10
0x21 +100
0x22 AM/PM
0x30 Power
0x31 Reset
0x32 Sleep
0x33 Sleep After
0x34 Sleep Mode
0x35 Illumination
0x36 Function Buttons
0x40 Menu
0x41 Menu Pick
0x42 Menu Up
0x43 Menu Down
0x44 Menu Left
0x45 Menu Right
0x46 Menu Escape
0x47 Menu Value Increase
0x48 Menu Value Decrease
0x60 Data On Screen
0x61 Closed Caption
0x62 Closed Caption Select
0x63 VCR/TV
0x64 Broadcast Mode
0x65 Snapshot
0x66 Still
0x80 Selection
0x81 Assign Selection
0x82 Mode Step
0x83 Recall Last
0x84 Enter Channel
0x85 Order Movie
0x86 Channel
0x87 Media Selection
0x88 Media Select Computer
0x89 Media Select TV
0x8A Media Select WWW
0x8B Media Select DVD
0x8C Media Select Telephone
0x8D Media Select Program Guide
0x8E Media Select Video Phone
0x8F Media Select Games
0x90 Media Select Messages
0x91 Media Select CD
0x92 Media Select VCR
0x93 Media Select Tuner
0x94 Quit
0x95 Help
0x96 Media Select Tape
0x97 Media Select Cable
0x98 Media Select Satellite
0x99 Media Select Security
0x9A Media Select Home
0x9B Media Select Call
0x9C Channel Increment
0x9D Channel Decrement
0x9E Media Select SAP
0xA0 VCR Plus
0xA1 Once
0xA2 Daily
0xA3 Weekly
0xA4 Monthly
0xB0 Play
0xB1 Pause
0xB2 Record
0xB3 Fast Forward
0xB4 Rewind
0xB5 Scan Next Track
0xB6 Scan Previous Track
0xB7 Stop
0xB8 Eject
0xB9 Random Play
0xBA Select DisC
0xBB Enter Disc
0xBC Repeat
0xBD Tracking
0xBE Track Normal
0xBF Slow Tracking
0xC0 Frame Forward
0xC1 Frame Back
0xC2 Mark
0xC3 Clear Mark
0xC4 Repeat From Mark
0xC5 Return To Mark
0xC6 Search Mark Forward
0xC7 Search Mark Backwards
0xC8 Counter Reset
0xC9 Show Counter
0xCA Tracking Increment
0xCB Tracking Decrement
0xE0 Volume
0xE1 Balance
0xE2 Mute
0xE3 Bass
0xE4 Treble
0xE5 Bass Boost
0xE6 Surround Mode
0xE7 Loudness
0xE8 MPX
0xE9 Volume Up
0xEA Volume Down
0xF0 Speed Select
0xF1 Playback Speed
0xF2 Standard Play
0xF3 Long Play
0xF4 Extended Play
0xF5 Slow
0x100 Fan Enable
0x101 Fan Speed
0x102 Light
0x103 Light Illumination Level
0x104 Climate Control Enable
0x105 Room Temperature
0x106 Security Enable
0x107 Fire Alarm
0x108 Police Alarm
0x150 Balance Right
0x151 Balance Left
0x152 Bass Increment
0x153 Bass Decrement
0x154 Treble Increment
0x155 Treble Decrement
0x160 Speaker System
0x161 Channel Left
0x162 Channel Right
0x163 Channel Center
0x164 Channel Front
0x165 Channel Center Front
0x166 Channel Side
0x167 Channel Surround
0x168 Channel Low Frequency Enhancement
0x169 Channel Top
0x16A Channel Unknown
0x170 Sub-channel
0x171 Sub-channel Increment
0x172 Sub-channel Decrement
0x173 Alternate Audio Increment
0x174 Alternate Audio Decrement
0x180 Application Launch Buttons
0x181 AL Launch Button Configuration Tool
0x182 AL Programmable Button Configuration
0x183 AL Consumer Control Configuration
0x184 AL Word Processor
0x185 AL Text Editor
0x186 AL Spreadsheet
0x187 AL Graphics Editor
0x188 AL Presentation App
0x189 AL Database App
0x18A AL Email Reader
0x18B AL Newsreader
0x18C AL Voicemail
0x18D AL Contacts/Address Book
0x18E AL Calendar/Schedule
0x18F AL Task/Project Manager
0x190 AL Log/Journal/Timecard
0x191 AL Checkbook/Finance
0x192 AL Calculator
0x193 AL A/V Capture/Playback
0x194 AL Local Machine Browser
0x195 AL LAN/WAN Browser
0x196 AL Internet Browser
0x197 AL Remote Networking/ISP Connect
0x198 AL Network Conference
0x199 AL Network Chat
0x19A AL Telephony/Dialer
0x19B AL Logon
0x19C AL Logoff
0x19D AL Logon/Logoff
0x19E AL Terminal Lock/Screensaver
0x19F AL Control Panel
0x1A0 AL Command Line Processor/Run
0x1A1 AL Process/Task Manager
0x1A2 AL Select Tast/Application
0x1A3 AL Next Task/Application
0x1A4 AL Previous Task/Application
0x1A5 AL Preemptive Halt Task/Application
0x200 Generic GUI Application Controls
0x201 AC New
0x202 AC Open
0x203 AC Close
0x204 AC Exit
0x205 AC Maximize
0x206 AC Minimize
0x207 AC Save
0x208 AC Print
0x209 AC Properties
0x21A AC Undo
0x21B AC Copy
0x21C AC Cut
0x21D AC Paste
0x21E AC Select All
0x21F AC Find
0x220 AC Find and Replace
0x221 AC Search
0x222 AC Go To
0x223 AC Home
0x224 AC Back
0x225 AC Forward
0x226 AC Stop
0x227 AC Refresh
0x228 AC Previous Link
0x229 AC Next Link
0x22A AC Bookmarks
0x22B AC History
0x22C AC Subscriptions
0x22D AC Zoom In
0x22E AC Zoom Out
0x22F AC Zoom
0x230 AC Full Screen View
0x231 AC Normal View
0x232 AC View Toggle
0x233 AC Scroll Up
0x234 AC Scroll Down
0x235 AC Scroll
0x236 AC Pan Left
0x237 AC Pan Right
0x238 AC Pan
0x239 AC New Window
0x23A AC Tile Horizontally
0x23B AC Tile Vertically
0x23C AC Format

Egalement dans cette section


Design - Fabrication
Conçu et fabriqué par:
Tomi Murovec
FabLab Manager - UBO Open Factory



DI-Box (Direct Input Box)

A DI-Box is a device usually used between a musical instrument and a mixing desk/console.

Its main role is to transform an asymmetric input signal of high impedance (e.g. from a guitar pickup) to a symmetric signal of low (or medium) impedance.



Spatialiseur Binaural

L'objectif de ce projet est de créer à la fois un programme permettant placer une source sonore dans un espace tridimensionnel et un contrôleur permettant d'avoir une commande manuelle sur ce programme.

Le projet a été créé par Yannick Magnin pour son stage à UBO Open Factory.

Le documentation du projet (en PDF) peut être télécharge sur le lien sur cette page.



Arduino MIDI Synth

This projects uses the MIDI protocol to send musical notes via USB-HID connection to a computer, where it can be used to play virtual instruments.

The project is in progress and will be updated as it progresses.




Entourloop is an audio looper for raspberry pi, autonome, easy to use and to rebuilt. It works thanks to : PureData patch, working with sync audio loops Python program, reading serial from Arduino extra web UI, which allows people to easily understand what is going on into the looper, and interact without the hardware.




Ce projet a été lancé pour démontrer que des instruments acoustiques encore plus complexes peuvent être construits dans un environnement FabLab à l'aide d'outils manuels et numériques.

Currently in construction (the website and the ukulele :) )



Ressenti Musique

Ressenti Musique, VIBZH
Vêtement pour ressentir la musique en salle de concert grâce à des vibrations pour personnes déficientes auditives.
Membres de l’équipe: Alexandre VALENTIN, Théo BOUSSARD, Tanguy LOUIS-MARIE, Loïc GOASGUEN.



UBO Openfactory

Salle D133 Bâtiment D


Fait avec  par la Team UOF