LighTouch - Control music with the wave of a hand

A touch-less, streaming radio/alarm clock

Similar projects worth following
LighTouch is the second iteration of a prototype I 'completed' about a year ago . The premise is simple: a fully functional streaming radio/alarm clock that uses hand gestures as the sole interface and no physical contact with the device.

Playback, volume, and track changing are controlled by waving your hand above the device.

The two primary components to accomplish this are simply a raspberry pi and an ultrasonic sensor. Everything else is just for flair!

LighTouch is meant to be a general control interface for non-visual medium (music in this case, but there are many other applications).  The idea behind the project is to make playing and controlling your music as simple as waving your hand.  The code is designed to interpret input from the ultrasonic sensor and use that information to control music playback.  

One of the first applications for this project is as a bed-side alarm clock.  The idea of which being rather than trying to fumble for a 'snooze' button, turning off your alarm is as simple as waving your hand over the clock.  

The controls are highly configurable, but in it's current state it's configured using MPD (pianobar is also working).  

To control the unit there are set distance criterias.  For instance there is a "ceiling" (the maximum distance the sensor will read input) set to 80cm.

Other such criterias are as follows:

0-10cm - Pause (LED off)

10-45cm - Volume control 0%-100% (LED brightens/dims)

46-69cm - DEAD ZONE (to prevent accidentally skipping to the next track when raising the volume....LED fully on)

70cm-80cm - Next Track (led will blink 3 times)

>80cm - Ceiling (no action taken)

Read more »


Arduino Code

ino - 7.12 kB - 10/05/2016 at 15:51


Basic version of Lightouch - (python script for RaspPi)

py - 2.48 kB - 10/05/2016 at 15:49


Alarm clock version of Lightouch - (python script for RaspPi)

py - 4.75 kB - 10/05/2016 at 15:47


View all 11 components

  • Phase 3 - Alarm Clock

    Thomas Clauser08/16/2014 at 05:03 0 comments

    The next step along the path was to include the alarm clock functionality in addition to standard music controls making this a bedside gadget.

    Making an alarm clock in python is fairly straightforward so I wanted to focus instead on the controls. The alarm goes off daily according to the time you set in the python script.  

    When that timestamp is hit the current song will play, the LCD will turn on displaying the current date/time, and the LED will go to full brightness.

    To turn off the alarm you have two choices; snooze or off

    Sticking with the idea of a 100% touch-less interface and wanting to leverage the controls that are already built in for music control I settled on the following for now:

    Snooze = Waving your hand over 10cm above the device pauses the playback for 7 minutes and leaves the LCD with date/time on.  The motion is similar to quickly swiping the air above the clock

    Alarm Off = Bringing your hand down to 0cm on the device turns off the playback, turns off the LCD backlight and LED, and resets the alarm for the next day.  The motion is similar to bringing your hand down onto the device (like hitting off button on your alarm clock)

    I'm merging this capability in the existing code but I'm leaving the code untouched so you have the option of music player or music player+alarm clock.

    Read more »

  • Phase 2 - Prototype (software)

    Thomas Clauser08/10/2014 at 18:19 0 comments

    I'm by no means a developer.  I find a great deal of enjoyment in 'tinkering' with different programming languages and I prefer to learn as a go.  To me it's like visiting a new country and trying to learn the language on the fly rather than in a book.  While there's a certain appeal to that approach it can have some downfalls such as inefficient code.

    My first python scripts were functional, but UGLY so I've taken the time to rewrite them but realize there's still a ways to go.  The goal is overall stability and performance.

    There are two pieces of code that do all of the heavy lifting; the python script on the raspi's side and the arduino sketch.

    • This is script is responsible for the following:
      • Receive commands from the ultrasonic sensor via the arduino's serial interface
      • Control the MPD interface
      • Set system volume
      • Retrieve/Send MPD information to the LCD via the arduino's serial interface
      • Monitor time and act as an alarm clock
      • Send Alarm Clock notification to the LCD/LED via the arduino's serial interface


    Read more »

  • Phase 2 - Prototype (hardware)

    Thomas Clauser08/09/2014 at 01:41 0 comments

    After I got my concept code down on the arduino platform, I let the project sit for a while.  As it was the only music you could play was if it was already stored on the sdcard in the mp3 shield.  What is this?  The Dark Ages?  All music should be streamed over a WiFi connection in infinite quantity and diversity!  However making all that happen in an arduino platform is a little bit more work that I was willing to do.

    Enter the raspberry pi.  This $35 board solves all of those problems in one nice, neat little package.  One raspbian install, a couple python package installs, and an ultrasonic on the GPIO later and everything appeared to be working.  

    I had read other posts about using an ultrasonic sensor with a raspberry pi and how the accuracy is somewhat lacking because of the fact that the GPIO has to go through the processor of the raspberry pi which can be affected by load.  So you don't get a standard, consistent measurement.  That was absolutely confirmed by my tests.

    So my idea was to offload those cycles into a 'middle-ware' arduino.  That way the only communication to the raspberry pi would only for actionable events and not 50 pings a second going through the GPIO.

    I chose a pi alamode to keep the footprint small.  Initially I was just going to use it as a stacked shield, but poor planning on the case I purchased didn't allow for that space wise, so I compromised on just extending the leads.  

    At that point I wanted to add some kind of display to this (other than the LED).  I chose to keep the load on the arduino as much as possible and bought a blue 16x2 LCD shield to sit on top of the pi alamode.  Now the arduino is both reading and writing via the raspberry pi's GPIO.

    So just to recap, the ultrasonic sensor, the ultrabright blue LED, and the 16x2 LCD shield are all connected to the pi alamode.  The pi alamode interprets all the ultrasonic signals and writes that information (when appropriate) over the raspberry pi's GPIO.  The raspberry pi then sends data (like Artist/Song info) over GPIO to the pi alamode to display information on the LCD.

    Read more »

  • Phase 1 - Concept

    Thomas Clauser08/07/2014 at 00:32 0 comments

    LighTouch was an idea I had as I was just diving into Arduino. Like anyone getting started, I bought an Uno and three random shields just to play with (music shield, bluetooth, and ultrasonic range finder). To that end, I got each of them up and running in record time and got bored. So what was the next logical step? Right... figure out how many of these shields can I use at the same time. In this case, a music shield and ultrasonic range finder made the cut.

    The idea is pretty simple; an mp3 player that you never have to touch. Simply hold your hand over the device to adjust volume, pause, and move to the next track. All the commands basically key on the distance of your hand from the sensor.

    A little modification of the demo code for both, some enclosure work, and before i knew it I had a pretty functional little prototype.

    Here's the current control scheme:

    0-7cm = Pause (LED OFF)

    7-30cm = Lowest Volume->Highest Volume (LED DIM)

    30-50cm = Highest Volume (LED ON)

    50-55cm = Next Track (LED OFF then ON)

    So basically the setup works based on your hand's distance from the sensor with feedback given by the LED so you know where you are in the control scheme. There's 'dead zones' setup to avoid accidentally moving from volume mode to next track. For instance, once you're at the max volume (30cm) , there's a +20cm dead zone until you hit the next track and the LED turns bright so that you know you're at the max volume.

    Whenever you move your hand away, and the distance becomes 'infinite' (ie, the ceiling) it locks in the last distance it recorded for your hand. So basically you move your hand to the volume you want, then slide your hand off to the side to lock it in.

    To pause, move your hand close to the sensor until the LED turns off, then slide your hand away.

    To change volume you raise your hand up or down while the LED is dimly lit, until it's brightest (then you're at max volume)

    Once you're at max volume, you can pop your hand up, watch for the LED to turn off, then back down to move to the next track (then you're back in volume mode, or just move your hand off to the side).

    I plan on expanding on this idea. Ultrasonic proves to be a very simplistic, but very precise user interface for just about everything I've tried it on.

    What's next? An alarm clock that I can just wave my hand over to shut it off.


    Read more »

View all 4 project logs

  • 1
    Step 1

    For the finished product, I'm using a Pi Alamode GPIO shield to act as the interface between Pi and the ultrasonic sensor/LCD as well as some custom soldered boards to ensure placement in the case.  In this example, I'm going to use a arduino-compatible connected via USB cable and leave out the LCD for ease of explanation.  This how-to assumes you have a basic knowledge of installing using Raspbian and familiarity with the arduino platform/environment.

  • 2
    Step 2

    Install and setup Raspbian on your Raspberry Pi

    Insert your SD Card, plug in a monitor/keyboard, and boot up

  • 3
    Step 3

    Login using standard credentials (user:pi pass:raspberry) and upgrade/install the following packages:

    sudo apt-get update && sudo apt-get dist-upgrade
    sudo apt-get install mpd mpc python-serial python-mpd python-alsaaudio


    (to force audio to go through HDMI or Analog, go to the Advanced Options in sudo raspi-config)

View all 10 instructions

Enjoy this project?



Thomas Clauser wrote 07/29/2014 at 00:28 point
Thanks! I've seen similar things out there. This is just a combination of things and time I have available. Once I refine the software and interface functions I fully intend to make much more streamlined package (with more capability)!

  Are you sure? yes | no

Adam Fabio wrote 07/28/2014 at 16:08 point
Now this is pretty darn cool! I like the idea of waving my hands - but I'm notorious for turning off alarm clocks without waking up! Would it be hard to add some sort of code to the disarm? i.e. like one wave within 6 inches of the clock, and a second at 1-2 feet? Even I wouldn't be able to do that in my sleep!

  Are you sure? yes | no

Thomas Clauser wrote 07/28/2014 at 16:32 point
Thanks! That's exactly what I was thinking. Snooze would be just a simple hand wave to shut it off for a couple minutes. But then some kind of drastic gesture to actually sleep the alarm (like having to get up out of bed to reach the distance it requires to turn off)

  Are you sure? yes | no

Mike Szczys wrote 08/04/2014 at 15:34 point
Can you trick these sensors with parabolic reflectors? If so, you place one on the wall high above this and you have to get across the room to be far enough away. Ha!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates