How to Create Gesture-Controlled LED Strips with Arduino

In this article, we will explore the APDS-9960 gesture sensor and how to use it with WS2812B to control Neopixel LED strips.

We can control the LED strip using simple gestures. Moving your hand left or right will change the direction of the running LEDs, while moving your hand up or down will change their colors.

APDS-9960 RGB and Gesture Sensor

The APDS-9960 RGB and gesture sensor is a small expansion board with ambient light, color measurement, proximity detection, and non-contact gesture capabilities.

How to Create Gesture-Controlled LED Strips with Arduino

APDS-9960 RGB and Gesture Sensor.

This sensor has many functions and can also be used as a proximity sensor. It is mainly used in smartphones to reduce screen brightness in dark environments or to disable the touchscreen when answering a call. This is the same sensor used in the Samsung Galaxy S5 and is possibly one of the cheapest and best gesture sensor modules on the market.

The sensor module has a built-in UV blocking filter and four separate sensor diodes for different directions, compatible with the I2C protocol, making it very easy to integrate with Arduino.

Sensor Pin Distribution

● VL (optional power for IR LED)

● GND (ground)

● VCC (power supply for the module)

● SDA (I2C data)

● SCL (I2C clock)

Sensor Specifications

● Operating Voltage: 3.3V

● Size: 20mm X 15.3mm

● I2C Interface (0X39)

● Ambient Light

● Proximity

● Gesture Direction

WS2812B LED Strip

The WS2812B LED strip comes with 5050 RGB LEDs and integrates a very compact WS2812B LED driver IC.

WS2812B is an addressable LED strip, available in various models, sizes, and LED densities. In this article, I will use a 1-meter long strip with 30 WS2812B LEDs. These LEDs are waterproof and dustproof as they are encased in waterproof silicone.

How to Create Gesture-Controlled LED Strips with Arduino

The LED strip is encased in waterproof silicone.

The LEDs are connected in series, and since the driver is integrated into the LED, each driver is addressable. Having addressable LEDs allows us to control the brightness and color of each LED separately, making it easy to create complex effects. Additionally, the LED strip is very flexible and can be cut to any length.

How to Create Gesture-Controlled LED Strips with Arduino

A close-up view of the driver IC on the LED strip.

Now that we have a thorough understanding of the key hardware, let’s dive into the project!

Essential Components

● Arduino IDE

● FastLED Library

● Arduino UNO

● APDS-9960 Sensor

● WS2812B LED Strip

How to Create Gesture-Controlled LED Strips with Arduino

Required Hardware

Wiring the Hardware

**Note: You must power this module with 3.3V; if you attempt to use a power supply greater than 3.3V, you may damage the APDS-9960 module.

How to Create Gesture-Controlled LED Strips with Arduino

Connect the APDS-9960 to Arduino via I2C

The SCL pin of the APDS9960 should be connected to the SCL pin on the Arduino. This pin varies by your board model. Here are some common pin numbers:

● Arduino Uno: A5

● ATmega385 based Arduino boards: A5

● Leonardo: 3

● Arduino Mega: 21

The SDA pin should be connected to the SDA pin on the Arduino. In Arduino Uno or ATmega385 based Arduino, it is A4, in Leonardo it is 2, and in Arduino Mega it is 20.

VCC should be connected to 3.3V, and GND should be connected to GND.

Connect WS2812B to Arduino

The ground pin of the LED strip should be connected to the GND of the Arduino, while the data pin of the WS2812B should be connected to pin 7 of the Arduino.

For best results, connect the +5V pin of the LED strip to an external power supply. You can use a phone charger for this. If you have a strip with 30 LEDs, it will consume a total of 1.5A current, with each LED consuming 50mA current.

I powered the strip using the 5V pin of the Arduino because I did not have high brightness requirements. However, if you want to control more LEDs, you must use an external power supply.

How to Create Gesture-Controlled LED Strips with Arduino

Project hardware connected

Download Libraries and Upload Source Code to Arduino

Next, we need to upload the source code (click the link to access the code) and download the APDS-9960 library and FastLED library.

To upload the libraries to Arduino IDE, follow these steps.

Go to Sketch —> Include Library —> Add.ZIP Library. Repeat these steps for all libraries.

How to Create Gesture-Controlled LED Strips with Arduino

After adding the libraries, connect the Arduino board to the computer. Then go to Tools —> Board, and select Arduino UNO board.

Go to Tools —> Port —> COM PORT. In this case, it is COM3.

Before uploading the code, make sure to change the number of LEDs in the Arduino Sketch according to your requirements. This example uses a strip of 30 LEDs.

How to Create Gesture-Controlled LED Strips with Arduino

Copy and paste the code into Arduino, then select Upload.

After uploading the code, you can test your project. To test, move your hand left and right above the sensor and observe the animation on the LED strip.

WelcomeReward+Like+Comment+Share!

For more content, please click Read Original” 》》

Leave a Comment