I’m trying to make a slider and a button for dimming:
The slider is the dimmer %, from 0 to 100.
The button is dual state button, if it’s ON then my code will call a function and dimmer slider will not work, if It’s OFF then dimmer slider will work.
The problem is: The button andslider are working, but when I change the value of slider, it changes my button value!!
Here’s my code:
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
char auth[] = "My auth code";
void setup() {
Serial.begin(9600);
Blynk.begin(auth); // (BLYNK)
int autodimmer; // (BLYNK) Auto Dimmer Button
void loop()
{
Blynk.run(); // (BLYNK) Run
}
void DimmerFunction()
{
if (autodimmer >= 1)
{
// Code
}
else
{
// Do nothing
}
}
BLYNK_WRITE(V18) // (BLYNK) Botão Auto Dimmer
{
autodimmer = param.asInt();
if (autodimmer == 1) // If Auto dimmer is ON then calls function Dimmer()
{
DimmerFunction();
}
}
BLYNK_WRITE(V5) // (BLYNK) Slider Dimmer
{
dimmer = param.asInt(); // dimmer = Value got from dimmer Slider
if (autodimmer == 0) // If auto dimmer is OFF then set the dimmer according slider value
{
Set.dimmer(dimmer);
}
// If AutoDimmer button is true, then do nothing
}
Yes, I do… Probably is an issue with Blynk… When I print value of dimmer and autodimmer, the autodimmer prints “0” or “1” for sometime then start printing “24946”… When I slide the dimmer, it changes the another pin (Autodimmer) value!
Almost always a Blynker problem, not a Blynk problem.
If you are going to provide a cut down version of your sketch please ensure it compiles.
You have numerous errors in your sketch.
Here is an ESP version of your sketch with the corrections and Blynk performs as expected.
Serial Monitor:
I’m sorry, I love Blynk, it’s the best app ever made…
Sorry but what you meant with “Ensure you don’t have the mapping connected in the slider configuration.”… My english is not good at all…
Ok, I still got the same problem… When you slided it? Did you slided for some time? Because when I press Autodimmer button, it works for some slidings then it changes to “24946”…
Mapping - in the slider settings there is a “wire” between 0 and 100 range. If you have accidentally clicked the wire when you were setting the range from 0 to 100 the “wire” will have an additional circular symbol around the wire. Ensure additional circular symbol is not shown (mapping disabled).
I used both (vertical and horizontal slider) and tried with both ways send on release on and off. Will change back to Vertical and send on release on (which’s already ON)