Create a wireless presenter for your presentations with LittleBits

As a demo for a workshop I am giving next week, I created a wireless presenter to use for presentations.
The receiver is connected to the computer via the Arduino Bit. The wireless presenter is just a button connected to the Wireless TransmitterĀ Bit. When you press the button, the (powerpoint) presentation advances to the next slide.
The Arduino program (listed below) sends a left arrow key press to the computer whenever it receives a signal on the digital input.

2016-02-05 11.29.36 2016-02-05 11.30.08

Don’t like programming?

Replace the Arduino bit with the Makey Makey. Works like a charm!

Code

/**
 * When a button attachted to digital input 0 is pressed, send a keypress of the RIGHT ARROW KEY to the computer.
 * This only works on Leonardo-type Aruino's, like the LittleBit's version
 * Based on this example:
 * https://www.arduino.cc/en/Reference/KeyboardPress
 * Reference:
 * https://www.arduino.cc/en/Reference/KeyboardModifiers
 */

// include the keyboard library:
#include <Keyboard.h>

char rightArrowKey = KEY_RIGHT_ARROW;
int pin = 0; // pin number of digital port on Arduino

void setup() {
  // make pin an input and turn on the 
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(pin, INPUT_PULLUP);
  // initialize control over the keyboard:
  Keyboard.begin();
  // initialize serial port:
  Serial.begin(9600);
}

void loop() {
  while (digitalRead(pin) == LOW) { // do nothing until pin goes high
    delay(500);
  }
  Serial.println("Button press");
  // send right-arrow key:
  Keyboard.press(rightArrowKey);
  delay(100);
  Keyboard.releaseAll();
  // wait:
  delay(1000);
}