#define rgb_colorR 5
#define rgb_colorG 18
#define rgb_colorB 19
#define r_channel 0
#define g_channel 1
#define b_channel 2
#define pwm_frequency 5000
#define pwm_resolution 8
void setup() {
// put your setup code here, to run once:
ledcAttachPin(rgb_colorR,r_channel);
ledcAttachPin(rgb_colorG,g_channel);
ledcAttachPin(rgb_colorB,b_channel);
ledcSetup(r_channel,pwm_frequency,pwm_resolution);
ledcSetup(g_channel,pwm_frequency,pwm_resolution);
ledcSetup(b_channel,pwm_frequency,pwm_resolution);
}
void loop() {
// put your main code here, to run repeatedly:
rgb_color(255,0,0);
delay(500);
rgb_color(0,255,0);
delay(500);
rgb_color(0,0,255);
delay(500);
rgb_color(255,255,0);
delay(500);
rgb_color(255,0,255);
delay(500);
rgb_color(0,255,255);
delay(500);
}
void rgb_color(int r,int g,int b){
ledcWrite(r_channel,r);
ledcWrite(g_channel,g);
ledcWrite(b_channel,b);
}