Does this project spark your interest?

Become a member to follow this project and don't miss any updates


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 »

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 »

  • View all 4 project logs

    • 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

      Install and setup Raspbian on your Raspberry Pi

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

    • 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