EasyManua.ls Logo

Freenove ESP32 - Page 103

Default Icon
159 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Need support? support@freenove.com
101
Chapter 9 WS2812
www.freenove.com
The following is the code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "RGBLED_WS2812.h"
u8 m_color[5][3] = { { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, { 255, 255, 255 }, { 0, 0, 0 } };
void setup() {
setupRGBLED();
}
void loop() {
for (int i = 1; i < 6; i++) {
if (i == 1) {
for (int j = 0; j < 5; j++) {
setRGBLED(i, m_color[j][0], m_color[j][1], m_color[j][2]);
delay(500);
}
} else {
setRGBLED(i, 100, 15, 100);
delay(5000);
}
}
}
Initialize the WS2812 LED pins.
6
setupRGBLED();
When i=1, control the RGB LEDS to display the specified color. When i is not equal to 1, other patterns of
colored lights are displayed.
13
setRGBLED(i, m_color[j][0], m_color[j][1], m_color[j][2]);
RGBLED_WS2812.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef _RGBLED_WS2812_h
#define _RGBLED_WS2812_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include "Freenove_WS2812_Lib_for_ESP32.h"
#define LEDS_COUNT 4
#define LEDS_PIN 0
#define CHANNEL 0

Related product manuals