The aim of this guide to show how to set the color of the RGB LED on the ESP32 Cheap Yellow Display (CYD). RGB LED have three internal LEDs (Red, Green, and Blue) when combined can produce eight colors (Red, Green, Blue, Yellow, Purple, Cyan & White). I hear you that’s only seven colors, the eighth is Black – in other words the LED is turned off.
The code has been write as a class, the class is called “CYD_RGBLED.h”. First we will start off looking at the code we need to add to our program:
#include “CYD_RGBLED.h” – this will include the class code in our program
CYD_LED LED; – Create a Object for the LED
LED.begin(); – Now we need to Initialise LED Object
LED.set_Color(RED); – This will turn on the LED and set the color to RED, the red can be replaced with any of the six other colors.
LED.turnOff(); – this will turn off the LED
Demo code and copy of the class can be download here
No responses yet