Arduino Nano ESP32 - Dotstar LED Strip
In this tutorial, we are going to learn how to use Arduino Nano ESP32 to control DotStar RGB LED strip. In detail, we will learn:
- How to connect Arduino Nano ESP32 to the DotStar LED Strip
- How to program Arduino Nano ESP32 control the color and brightness of each individual LED on the led strip
- How to program Arduino Nano ESP32 to create the comet effect for the DotStar LED strip
|Arduino Nano ESP32
|USB Cable Type-C
|DotStar RGB LED Strip
|5V Power Adapter
|DC Power Jack
|(Recommended) Screw Terminal Adapter for Arduino Nano
Or you can buy the following sensor kit:
|DIYables Sensor Kit 30 types, 69 units
Overview of DotStar RGB LED Strip
the DotStar RGB LED Strip has three pins:
- GND pin: needs to be connected to GND (0V)
- CI pin: Clock pin that receives the clock signal. It should be connected to an Arduino Nano ESP32 pin.
- DI pin: Data pin that receives the control signal. It should be connected to an Arduino Nano ESP32 pin.
- 5V pin: needs to be connected to 5V of external power supply
This image is created using Fritzing. Click to enlarge image
How To Program For DotStar RGB LED Strip
- Include a DotStar library
- Declare a DotStar object
- Initializes the DotStar
- Set color (r. g, b) of each individual LED (called pixel) .
- Set brightness of all strip.
※ NOTE THAT:
- DotStar.setBrightness() is used for all pixel on LED strip. To set the brightness for each individual pixel, we can scale the color value.
- The values set by DotStar.setBrightness() and DotStar.setPixelColor() only take effect when DotStar.show() is called.
Arduino Nano ESP32 Code
The below code turns pixels to red one by one with a delay between each pixel
To get started with Arduino Nano ESP32, follow these steps:
- If you are new to Arduino Nano ESP32, refer to the tutorial on how to set up the environment for Arduino Nano ESP32 in the Arduino IDE.
- Wire the components according to the provided diagram.
- Connect the Arduino Nano ESP32 board to your computer using a USB cable.
- Launch the Arduino IDE on your computer.
- Select the Arduino Nano ESP32) board and its corresponding COM port.
- Open the Library Manager by clicking on the Library Manager icon on the left navigation bar of Arduino IDE
- Search “Adafruit DotStar”, then find the DotStar library by Adafruit
- Click Install button to install DotStar library.
- You will be asked to install the dependency. Click Install All button.
- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino Nano ESP32
- See the LED effect
Arduino Nano ESP32 Code - LED Strip Comet Effect
The below code provides the comet effect for the DotStar LED strip
※ NOTE THAT:
For any other LED effects, we offer the paid programming service