Media keyboard with Leonardo/Micro for Android?

Hi all,

I built a basic media keyboard using a Micro and the HID project library (link here), which convert’s my car’s steering wheel controls into six media buttons. Here’s the code:

#include "HID-Project.h"

const int pinButton = 3;
int data;

void setup() {
  //pinMode(pinButton, INPUT_PULLUP);

  // Sends a clean report to the host. This is important on any Arduino type.
  Serial.begin (9600);

void loop() {
  Serial.println (data);
    // See HID Project documentation for more Consumer keys

    if (data>340 && data <= 380) {
      Consumer.write(MEDIA_PLAY_PAUSE); }
    if (data>570 && data <= 600) {
      Consumer.write(MEDIA_PREVIOUS); }
    if (data>80 && data <= 120) {
      Consumer.write(MEDIA_NEXT); }
    if (data>410 && data <= 440) {
      Consumer.write(MEDIA_VOLUME_DOWN); }
    if (data>460 && data <= 490) {
      Consumer.write(MEDIA_VOLUME_UP); }
    if (data>10 && data <= 50) {
      Consumer.write(MEDIA_VOLUME_MUTE); }
    // Simple debounce

It all works fine on a Windows 7 PC with both Windows Media Player and Winamp, but on Android the MEDIA_PLAY_PAUSE function only pauses, never plays, and the MEDIA_PREVIOUS and MEDIA_NEXT functions don’t seem to work.

Is anyone aware of any other libraries, or just dedicated commands, that I can send on each button press to control music tracks on an android device?

Did you ever figure this out, or get an answer, I am looking at something simular and could really use the help.


Sorry Erik. I never got this working with Android, and had to stick to a Windows-based system for my solution.