So I have what seems like a simple project with an Esp8266-01 connected via wifi, using sliders to control individual colors of an RGB led strip (driven by transistors). I’ve done the project in the past, but have lost the code, so I’m redoing everything. I just can’t remember running into my current problem.
BLYNK_WRITE(V1)
{
int redValue = param.asInt();
analogWrite (redPin, redValue) ;
}
The variable redPin has been assigned to a pin elsewhere in the sketch. I am only able to post part of the sketch for now, until I have access to my laptop to copy paste the full thing. That should be irrelevant for now.
In the app, the slider is given a range of 0-1023 and assigned to V1. When uploaded to the esp and tested using a multimeter, I get 3.3v when the slider is set to 0 and 0v when set to 1023. I can’t find any reason why or where the signal is being inverted.
I’ve added serial to the sketch and displayed V1 (redValue) to confirm the appropriate value is being sent. So essentially what I have is:
analogWrite (redPin, 0);
giving me 3.3v on the pin and:
analogWrite (redPin, 1023);
giving me 0v on the pin…plus everything in between at intermediate values.
I know I could make the slider values inverted by changing from 0-1023 to 1023-0, but that messes with my zeRGBa that’s tied to the sliders.
Also, I realize I could probably easily remap the values in the sketch itself with
map(redValue,0,1023,1023,0);
but I’d rather know the why to what’s causeing the inversion in the first place.
Any help is much appreciated.