Random Nerd Tutorials
Shares

Gesture Slider Swiper with Arduino

Shares
This project was written by Emmanuel Odunlade and edited by Rui Santos.

 

In this post you’re going to learn how to set an Arduino UNO board as a USB HID keyboard and use gestures to swipe slides during a presentation.

How it works

Here’s a figure that describes exactly how everything works together:

If you like Arduino projects and you want to build more, we recommend getting the Arduino Step-by-step Projects – Build 23 Projects course.

Arduino UNO or Mega as a USB HID keyboard

The Arduino can be configured to emulate a keyboard and perform useful tasks. Attaching a pushbutton to an Arduino digital pin and with a button press, you can write a password, copy+paste, up/down volume, up/down screen brightness, etc…

Although boards like the Arduino UNO can’t do this by default if you flash a new bootloader, you can make the Arduino UNO board turn into a USB HID keyboard.

An Arduino Uno/Mega has two microcontrollers: ATmega328 and 16u2. The 16u2 is normally used for USB to Serial communication. We can also use it as standalone AVR Microcontroller with (or without) USB functions as well.

HoodLoader2 gives you the option to reprogram the 16u2 of a normal Arduino Uno/Mega R3 with custom sketches. This means you can use the 16u2 as a normal USB AVR like an Arduino Leonardo board. You have a full compatible USB-HID core.

You can prepare your Arduino UNO or Arduino Mega to act as a keyboard with the HoodLoader2 bootloader by following the instructions in their official Wiki page.

Supported Arduino boards using Arduino IDE 1.6.7 or higher:

  • Uno (needs HoodLoader2 bootloader)
  • Mega (needs HoodLoader2 bootloader)
  • Leonardo
  • (Pro) Micro

Parts required

Here’s a complete list of the components you need for this project:

  • Arduino UNO, Mega, Leonardo, ProMicro or any other 8u2/16u2/at90usb8/162/32u2/32u4 compatible board
  • 2x Ultrasonic sensor – HC-SR04 (eBay)
  • 2x LEDs (eBay)
  • 2x 220 ohm resistors (eBay)
  • Breadboard (eBay)
  • Jumper wires (eBay)

Uploading code

To use your Arduino as a keyboard, you need to install the HID Library.

Installing the HID Library

  1. Click here to download the HID library. You should have a .zip folder in your Downloads folder
  2. Unzip the .zip folder and you should get HID-master folder
  3. Rename your folder from HID-master to HID
  4. Move the HID folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE

Copy the following code to your Arduino IDE and upload it to your Arduino board:

Schematics

Wire your circuit accordingly to the schematic below:

Now, if you move a hand in front of the left ultrasonic sensor, your Arduino sends a Left keyboard command resulting in moving the presentation to the previous slide.

Wrapping up

I have always been fascinated by natural user interfaces, the idea of things like the sixth sense (which I hope to share a tutorial on someday) and generally all things that makes telekinesis look like a possibility.

Thus I believe there are several updates that could be made to this project. Instead of using ultrasonic sensors and controlling sides what if we attached an Electroencephalogram (EEG) headset and then do more complex stuff like draw shapes and achieve all this within the simplicity frame the Arduino provides.

So the possibilities are endless. Hack it up!

Leave a Comment:

Add Your Reply