I would like to be able to control led output through PWM frequency like this function:
Code: Select all
function led(r,g,b,frequency)
--RED(GPIO15),GREEN(GPIO12),BLUE(GPIO14)
pwm.setduty(6,g)
pwm.setduty(5,b)
pwm.setduty(8,r)
pwm.setclock(6, frequency)
pwm.setclock(5, frequency)
pwm.setclock(8, frequency)
end
How can I convert this function into arduino esp32 function?
Fro the moment I am using this function:
Code: Select all
void ledcAnalogWrite(uint8_t channel, uint32_t value, uint32_t valueMax = 255) {
// calculate duty, 8191 from 2 ^ 13 - 1
uint32_t duty = (8191 / valueMax) * _min(value, valueMax);
// write duty to LEDC
ledcWrite(channel, duty);
}
Code: Select all
ledcAnalogWrite(LEDC_CHANNEL_0_R, 0);
ledcAnalogWrite(LEDC_CHANNEL_1_G, 0);
ledcAnalogWrite(LEDC_CHANNEL_2_B, 255);
Any ideas?