telecommande-presentation.ino

Arduino Leonardo — Board Fiche · File : telecommande-presentation.ino · Language : Arduino · Use case : Boîtier de présentation : bouton suivant / précédent pour diaporamas

HID arrow keys drive any slideshow (PowerPoint, Impress, web). A two-button pocket box replaces a €40 clicker.

Hardware required

An Arduino Leonardo (ATmega32U4, 16 MHz, 5 V) with native USB: the board can pose as a keyboard or a mouse. 2 push buttons + an enclosure.

Wiring

Buttons to GND on 2 and 3; powered by a powerbank through the USB port.

How it works

Each press sends an arrow key; the 250 ms delay debounces and prevents multi-slide jumps. In the Arduino IDE, select « Arduino Leonardo » and the port, then Upload. Caution: a sketch that sleeps too fast can « lose » the USB port; hold RESET for 12 s to wipe the bootloader.

Going further

Add KEY_ESC to start/abort the show, or a third button for presenter mode.

telecommande-presentation.ino

// 2 boutons : fleche droite (suivante) et gauche (precedente).
#include <Keyboard.h>

const int B_SUIV = 2, B_PREC = 3;
bool a1 = HIGH, a2 = HIGH;

void setup() {
  pinMode(B_SUIV, INPUT_PULLUP);
  pinMode(B_PREC, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  bool s = digitalRead(B_SUIV);
  if (s == LOW && a1 == HIGH) { Keyboard.write(KEY_RIGHT_ARROW); delay(250); }
  a1 = s;
  bool p = digitalRead(B_PREC);
  if (p == LOW && a2 == HIGH) { Keyboard.write(KEY_LEFT_ARROW); delay(250); }
  a2 = p;
}

← Back to the board