Simple Gesture Control Using IR Sensors

Introduction: Simple Gesture Control Using IR Sensors

Controlling things using gesture is always exciting and fun but, with the sensors available in the market for recognizing gestures are pretty costly. So how can we make a simple gesture control using few dollars?
Well, IR sensors when used properly can be used to recognize simple gestures. Using 2 IR sensors we can make it recognize four kinds of gestures, which are left swipe, right swipe, waving your hand and moving your hand forward and backwards.

We will make this project using SLabs-32. It has an onboard TFT screen which we can make use of by displaying images when a particular gesture is recognized.

SLabs-32 comes handy with these kind-off projects, we have a lot of resources onboard on SLabs-32. We can also use the SD card to display images onto the TFT screen and change whenever we swipe left or right.

To keep things simple we will just display an emoji which looks left or right depending on our movement.

To get your own SLabs-32 click on this link

Step 1: List of Materials

For this project you would require :

  • SLabs-32 (v0.1)
  • 2 x IR sensors

Step 2: Removing the IC for Analog Values

An IR sensor normally gives us a digital output, either a 0 or 1. We have to remove the IC from the IR sensor and use a jumper wire to connect to the receiver of the IR sensor. This will give us analog values from the IR sensor. To do that trace down the receiver pin connected to the IC holder's pin. Observe the picture in this step to get an idea of how to trace your receiver pin. I have highlighted the trace of the receiver for better understanding.

Connect a jumper wire in that receiver pin of the IC to use this sensor as an analog sensor

Step 3: Working of Gesture Control

To recognize gesture movements using IR sensors, we use a trigger mechanism. We have two IR sensors, lets name them for our convenience left-IR and right-IR. Left-IR being the IR sensor on the left side and right-IR being the IR on the right side. When we swipe left, we move our hand from right to left. The right-IR sensor detects this movement first and raises a flag. Now only, if any movement is detected at the left-IR sensor it recognizes it as a left swipe. Similar for right swipe as well. We don't want any wrong results were if we just move our hand at the right IR sensor then it shows as to right swipe. Thus to make it more sensible we use this mechanism.

To recognize the waving gesture we simply count the number of times the person swiped right and left consecutively within a period of time, which in our case is 5 seconds.

Step 4: Calibration of Sensors

Now the IR sensor placement is very important, as they will decide your threshold values. Notice the values of IR sensor when you place your hand near the IR sensors, use these values decide your threshold for sensing any movement near your IR sensor. Also, place your IR sensors next to each other with approximately 3 cm of gap between them.

Step 5: Hardware Connections

Connect the analog output from the two IR sensors to the analog inputs of SLabs-32.

To make things simple use a tape to hold your IR sensor down to one place. If you accidentally move your IR sensor then the whole sensor values have to be re-calibrated again. So, use a tape or anything which holds it down to one place

Step 6: Programming SLabs-32

Just upload the sketch attached to this project.

Observe your IR sensor readings in the serial monitor. Make changes if you have to, if the threshold values do not match your IR sensor readings. Adjust the values and set the threshold as you want to.

Step 7: Become Tony Stark

Well not really but now you do have a low-cost gesture control mechanism which you can use it with anything you want, just like Tony Stark from Iron-man does with Jarvis. Ok not really but at least this is a start.



    • Tiny Home Contest

      Tiny Home Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Fix It! Contest

      Fix It! Contest

    4 Discussions


    Question 2 months ago

    Hi, can you explain your algorithm of your detection of gesture?

    Is that sensor_init() is to check whether hand is put at the center before start to perform gesture? or what is the purpose?

    Secondly, how to detect swipe left/right? By detecting left IR get blocked and consequence right IR get blocked then consider swipe right?

    1 more answer


    Yes "sensor_init()" is used to check if any hand is placed at the center or not. To your second doubt, yes you are correct, along with that I also have a time-out of 5 seconds, meaning after detecting some object at left IR, I should detect the object at the right IR within 5 seconds to conclude the gesture as RIGHT SWIPE.


    It means that it notifies the processor that some event has occurred.