How can I control my button and slider at a time?

I want to control my button and slider at a time . When button is on then slider work otherwise slider should not work.

[Unformatted code removed by moderator]

@Shahzad please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Please edit your post with triple backticks :stuck_out_tongue_winking_eye:

Easy

//declaration before setup zone
int flag, ledValue ,previousledvalue ;


BLYNK_WRITE(V2) { //sw button
  if (flag==1) {
    led1.off();
    flag = 0;
    //digitalWrite(2,LOW);
    Serial.println("LED on V1: off");
  } else {
    led1.on();
    flag = 1;
  }

  BLYNK_WRITE(V1) { //slider,here you’ll get 0 or 255
    if (flag == 1) {
      ledValue = param.asInt();
      previousledvalue = ledValue;
      ledcWrite(ledChannel3, ledValue);
      Serial.print("V1 Slider value is: ");
      Serial.println(ledValue);
      //digitalWrite(2,HIGH);
      Serial.println("LED on V1: on");
    } else {
      Blynk.virtualWrite(V1, previousledvalue );//restore previous Slider value, slide forbidden
    }
 }

@PeteKnight , the guy never replied :joy::joy::joy:

I think he came back and grabbed your code example, but ignored my request to fix his code formatting, so his code was deleted.
That’s why I always wait until they’ve fixed the code formatting until I bother reading or replying to their post. :wink:

Pete.

1 Like

But no thanks at all for helping him :rofl:

1 Like