I am using ESP32 with the PWM led. I want to control led by Blynk slider widget. I am reading reading V1 value. How to use int pinValue from V1 in loop function for ledcWrite
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Network";
char pass[] = "password";
public BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
return 0;
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
ledcSetup(0,5000,8);
ledcAttachPin(22,0);
}
void loop()
{
Blynk.run();
ledcWrite(0, value);
}
@davidkhan My example was a bit more complex becasue it was using the zeRGBa and mapping to HEX for changing widget colours
But if all you want to do is adjust the PWM range of a single LED with a slider on the ESP32 then it can be as simple as this (with the required ESP channel and frequency settings of course)…
Using the 8-bit range, you set your sliders MIN-MAX to 0-255, or perhaps 255-0 for inversely driven pins… adjust the range for higher bit rates if wanted, e.g. 10bit and 0-1024 or 12 bit 0-4096 for servos, etc.