Usually IR sensors are used to detect the presence of human or any other infrared objects. But the Grove Human Presence sensor has 4 IR sensors integrated. You can not only detect human presence or motion, you could even use the data to determine the movement direction of the infrared object. As shown in the picture, when you wave your hand from different side of the sensor, you’ll get different signals.
So I decided to use the human presence detector to capture hand motions and use the motion captured to control YouTube playback. Because YouTube only allow you to fast forward 5 seconds every time you click the right button. With the Python code, I can fast forward 20 seconds every time I wave my hand.
Besides, you can reprogram the Python code to make different combination of keys. For example, you can use it to turn pages of your e-book.
To replicate the project, you can follow the following steps.
Connect your Arduino with your computer and the IR sensor. The IR sensor should be plugged into an I2C port.
Copy and paste the Arduino code below into your Arduino IDE. Then compile and upload it into your Arduino board.
Click ‘Tool -> Serial Monitor ’ to test the motion capture function.
After the test, copy and paste the Python code below into your Python editor. Remember to install the pyserial and pynput library. If you don’t know how to do it. Just open your terminal and type 'pip install pyserial' and 'pip install pynput'.
Execute the Python file and play with your own gesture controller!