LED
unknown
c_cpp
9 months ago
1.2 kB
3
Indexable
// LED pins
#define LED_PIN_1 3 //RED
#define LED_PIN_2 9 //GREEN
#define LED_PIN_3 8 //BLUE
#define LEDC_RED 0
#define LEDC_BLUE 1
#define LEDC_GREEN 2
#define LEDC_TIMER_8_BIT 8
#define LEDC_BASE_FREQ 5000 // use 5000 Hz as a LEDC base frequency
void initLED() {
// LED SETUP PWM
ledcAttachChannel(LED_PIN_1, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT, LEDC_RED);
ledcAttachChannel(LED_PIN_2, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT, LEDC_BLUE);
ledcAttachChannel(LED_PIN_3, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT, LEDC_GREEN);
}
//Запускаем светодиоды со значениями R,G,B
void LED_Control(int R, int G, int B) {
ledcWriteChannel(LEDC_RED, R);
ledcWriteChannel(LEDC_BLUE, G);
ledcWriteChannel(LEDC_GREEN, B);
}
/*
//Запускаем светоидоды с референсными значениями
void LED_Control(bool red, bool green, bool blue) {
ledcWriteChannel(LEDC_RED, 0);
ledcWriteChannel(LEDC_GREEN, 0);
ledcWriteChannel(LEDC_BLUE, 0);
if (red) ledcWriteChannel(LEDC_RED, R_value);
if (green) ledcWriteChannel(LEDC_BLUE, G_value);
if (blue) ledcWriteChannel(LEDC_GREEN, B_value);
}*/Editor is loading...
Leave a Comment