HID Help Volume Up\Down

Hi All,

Yes i am very new , just got my Arduino Leonardo two weeks ago.

to just dive into the problem.

What i like to do is to control the volume of the Windows PC .
Like a media keyboard is doing.
If you press volume up the master volume is going up and down the same way.
So I was thinking just add the correct items int the USBAPI.h and HID.cpp
so I fount on the internet a web site that gave me (I think) the correct information about that.
For in the HID.cpp

0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x09, 0xe9, // USAGE (Volume Up)
0x09, 0xea, // USAGE (Volume Down)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x06, // INPUT (Data,Var,Rel)
0x09, 0xe2, // USAGE (Mute)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x06, // INPUT (Data,Var,Rel)
0x95, 0x05, // REPORT_COUNT (5)
0x81, 0x07, // INPUT (Cnst,Var,Rel)

And .
0xe9, // Vulume up
0xea, // volume down

And in the USBAPI.h

#define Key_Volume_Up 0xB0
#define Key_Volume_Down 0xEA

So I also create a Test sketch

boolean running = false;

void setup() 
{
  // make pin 2 an input and turn on the 
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() 
{
  //if the button is pressed
  
  
  if(digitalRead(2)==LOW)
  {
  running = true;
  }
  if(digitalRead(2)==HIGH)
  {
  running = false;
  }
  if(running == true)
  {
    //Send the message
    Keyboard.press(Key_Volume_Up);
    running = false;
  }

}

But for some reason it only repeats a 9 all the time until I power down the Arduino.
Can someone give me som pointers in the ride direction.
I used the following websits to get the HID information.
http://www.freebsddiary.org/APC/usb_hid_usages.php

Thanx in advanced

Bart

HI Bart,

After a keyboard press(), you must also release() it OR use keyboard.print()

the bios (I assume) can only handle 9 keypresses in parallel it seems.

read - http://arduino.cc/en/Reference/MouseKeyboard -

oke that was a stupid mistake of me :~

indeed that soft the problem of all the 9 that was repeating.

I added a Keyboard.releaseAll();
And a delay and it was starting to work.

But I am still getting only a 9 instad of the volume up command

Fount it :slight_smile:

Tanx to the writers of the below link it is working :slight_smile: