In this tutorial we will learn how to control the LED brightness using the gesture sensor and arduino.
Watch the video!
Step 1: What You Will Need
- Gesture Color Proximity APDS9960 I2C sensor
- Arduino UNO (Or any other Arduino)
- LED
- 1K ohm resistor
- Jumper wires
- Breadboard
- Visuino program: Download Visuino
Step 2: Brought by PCBWay
Thank you PCBWay for supporting this tutorial and helping users learn more about electronics.
What I like about the PCBWay is that you can get 10 boards for approximately $5 which is really cost effective for professional made boards, not to mention how much time you save!
Go check them out here. They also offer a lot of other stuff in case you might need it like assembly, 3D printing, CNC machining and a lot more.
Step 3: The Circuit
- Connect Sensor Pin [GND] to Arduino board pin [GND]
- Connect Sensor Pin [Vin] to Arduino board pin [3.3V]
- Connect Sensor Pin [SDA] to Arduino board pin [SDA]
- Connect Sensor Pin [SCL] to Arduino board pin [SCL]
- Connect Arduino board pin [GND] to LED negative pin [-]
- Connect Arduino board digital pin [5] to 1k ohm resistor
- Connect 1k ohm resistor second pin to LED positive pin [+]
Step 4: Start Visuino, and Select the Arduino UNO Board Type
The Visuino: https://www.visuino.com also needs to be installed. Download Free version or register for a Free Trial.
Start Visuino as shown in the first picture Click on the “Tools” button on the Arduino component (Picture 1) in Visuino When the dialog appears, select “Arduino UNO” as shown on Picture 2
Step 5: In Visuino Add & Set Components
- Add “APDS9960” component
- Add “Clock Multi Source” component
- Add “Up/Down Counter” component
- Add “Analog Value” component
- Add “Integer To Analog” component
- Add “Analog Multi-Source Merger” component
Select “UpDownCounter1” and in the properties window:
- set “Max” > “Value” to 10
- set “Max” > “Roll Over” to False
- set “Min” > “Value” to 0
- set “Min” > “Roll Over” to False
Select “IntegerToAnalog1” and in the properties window set “Scale” to 0.1
Step 6: In Visuino Connect Components
- Connect “GestureColorProximity1” Control pin I2C to Arduino I2C pin [In]
- Connect “GestureColorProximity1” pin [Up] to “ClockMultiSource1” pin [In]
- Connect “ClockMultiSource1” pin [0] to “AnalogValue1” > “Set Value1” pin [In]
- Connect “ClockMultiSource1” pin [1] to “UpDownCounter1” [Reset]
- Connect “GestureColorProximity1” pin [Down] to “AnalogValue1” > “Set Value2” pin [In]
- Connect “GestureColorProximity1” pin [Left] to “UpDownCounter1” pin [Down]
- Connect “GestureColorProximity1” pin [Right] to “UpDownCounter1” pin [Up]
- Connect “UpDownCounter1″ pin [Out] to “IntegerToAnalog1” pin [In]
- Connect “AnalogValue1″ pin [Out] to “AnalogMultiMerger1” pin [0]
- Connect “IntegerToAnalog1″ pin [Out] to “AnalogMultiMerger1” pin [1]
- Connect “AnalogMultiMerger1″ pin [Out] to Arduino PWM pin [5]
Step 7: Generate, Compile, and Upload the Arduino Code
In Visuino, at the bottom click on the “Build” Tab, make sure the correct port is selected, then click on the “Compile/Build and Upload” button.
Step 8: Play
If you power the Arduino module & move the hand Up or Down above the Sensor the LED will turn On or Off, and if you move the Left or Right the LED will change its brightness.
Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Tutorial, you can download it and open it in Visuino: https://www.visuino.com
Download gesture-led-on-off-dim.zip