HID/examples/Consumer/Consumer.ino

39 lines
838 B
Arduino
Raw Normal View History

2015-01-02 15:59:33 +00:00
/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
Consumer example
Press a button to play/pause music player
2015-11-06 20:25:14 +00:00
You may also use SingleConsumer to use a single report.
See HID Project documentation for more Consumer keys.
https://github.com/NicoHood/HID/wiki/Consumer-API
2015-01-02 15:59:33 +00:00
*/
2015-08-24 15:05:20 +00:00
#include "HID-Project.h"
2015-01-02 15:59:33 +00:00
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.
Consumer.begin();
}
void loop() {
if (!digitalRead(pinButton)) {
digitalWrite(pinLed, HIGH);
// See HID Project documentation for more Consumer keys
2015-01-02 15:59:33 +00:00
Consumer.write(MEDIA_PLAY_PAUSE);
// Simple debounce
2015-01-02 15:59:33 +00:00
delay(300);
digitalWrite(pinLed, LOW);
}
}