How to make a switch so that a slider works on the 8266

how I would like a little bit of your help, I’m trying to make a sitch to be able to run a slidder, but I can not do it … I have this programming but I do not know how to do it … someone to help me please
I was trying to put conditional but I do not think I’m doing, because when channel 1 is on you should take the values ​​of the slidder but it does not work

Welcome to cayenne community @jorge_quishpe194 , your code should work fine once you initialize sliderValue and sli globally. can you copy and paste your code here in place of the sending a photo.

thanks for your help… but it dont works…
here my code

void setup() 
{
  pinMode(4,OUTPUT);
  pinMode(5, OUTPUT);
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
  int sli;
int sliderValu;
}

void loop() 
{
  Cayenne.loop();
  Cayenne.virtualWrite(0, analogRead(A0));
  Cayenne.virtualWrite(2, analogRead(A0));
  delay(250);
}

CAYENNE_IN(3) //choose a free virtual channel … there are many
{
int sliderValue = (getValue.asInt());
analogWrite(5, sliderValue);
}


CAYENNE_IN(1)
{
 
  int i=getValue.asInt();
digitalWrite(4,i);
if (i==1)
{
  int sli = sliderValue;
  analogWrite(2, sli);
}

}

try this code:

unsigned long lastMillis = 0;
int i;
int sli;
int sliderValue;

void setup()
{
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop()
{
  Cayenne.loop();
  if (i == 1)
  {
    sli = sliderValue;
    analogWrite(2, sli);
  }
  if (millis() - lastMillis > 10000) {
    lastMillis = millis();
    Cayenne.virtualWrite(0, analogRead(A0));
    Cayenne.virtualWrite(2, analogRead(A0));
    delay(250);
  }
}
CAYENNE_IN(3) //choose a free virtual channel … there are many
{
  sliderValue = (getValue.asInt());
  analogWrite(5, sliderValue);
}


CAYENNE_IN(1)
{

  i = getValue.asInt();
  digitalWrite(4, i);
}
1 Like

THANK YOU !!! :smile: your code help me… it works fantastic…
can i ask you another favor… I try to connect with my cellphone, but i cant…Do I need to be connected to the same network? or what do I do?

it works anywhere in the world, if you have an internet connection.

i ask it because when i try to control the slidder show me a message


and i don’t know what is the problem because the button works and the slider do not

the slider on the App is defect, The team working to solve it.

2 Likes

i didnt know it… thanks for the help…

till this bug is fixed you can try this. if you are using android app then you can make a project and open the shared link on mobile google chrome browser in desktop mode.

2 Likes

like this : Read Only Dashboard? - #10 by SuperNinja

2 Likes

I understand … Thanks