Skip to content

Instantly share code, notes, and snippets.

@finsprings
Created March 5, 2010 04:25
Show Gist options
  • Select an option

  • Save finsprings/322448 to your computer and use it in GitHub Desktop.

Select an option

Save finsprings/322448 to your computer and use it in GitHub Desktop.
#include <SimpleRemote.h>
#include <Bounce.h>
const byte PLAY_BUTTON_PIN = 5;
const byte VOL_PLUS_BUTTON_PIN = 6;
const byte VOL_MINUS_BUTTON_PIN = 7;
const unsigned long DEBOUNCE_MS = 20;
Bounce playButton(PLAY_BUTTON_PIN, DEBOUNCE_MS);
Bounce volPlusButton(PLAY_BUTTON_PIN, DEBOUNCE_MS);
Bounce volMinusButton(PLAY_BUTTON_PIN, DEBOUNCE_MS);
SimpleRemote simpleRemote;
void setup()
{
pinMode(PLAY_BUTTON_PIN, INPUT);
pinMode(VOL_PLUS_BUTTON_PIN, INPUT);
pinMode(VOL_MINUS_BUTTON_PIN, INPUT);
// enable pull-ups
digitalWrite(PLAY_BUTTON_PIN, HIGH);
digitalWrite(VOL_PLUS_BUTTON_PIN, HIGH);
digitalWrite(VOL_MINUS_BUTTON_PIN, HIGH);
simpleRemote.setup();
}
void loop()
{
simpleRemote.loop();
if (playButton.update())
{
if (playButton.read() == LOW)
{
simpleRemote.sendPlay();
}
else
{
simpleRemote.sendButtonReleased();
}
}
if (volPlusButton.update())
{
if (volPlusButton.read() == LOW)
{
simpleRemote.sendVolPlus();
}
else
{
simpleRemote.sendButtonReleased();
}
}
if (volMinusButton.update())
{
if (volMinusButton.read() == LOW)
{
simpleRemote.sendVolMinus();
}
else
{
simpleRemote.sendButtonReleased();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment