[SOLVED] Dim an LED and start button

Hello all. Recently I’ve started a very small project ( I’m a beginner) using ESP8266 and Blynk app. What I wanna to do is : dim an LED, but only when the “START” button (from the Blynk app) is ON and when the button if OFF, the brightness of the LED should remain. In the app there is only one button and one slider.

Is it possible to create such a project, where you can control and LED (or any thing), but only when you “have a confirmation” ? In case you have some ideas, please share.
Thank you in advance. Wish you a beautiful day.

The arduino sketch :

define BLYNK_PRINT Serial
include <ESP8266WiFi.h>
include <BlynkSimpleEsp8266.h>

char auth[] = "xxxxxx";
const int ledPin =5;//pin on the ESP8266
int x =0;

void setup()
  Blynk.begin(auth, "xxxxx", "xxxxx");

  x = param.asInt();
  Serial.print("Button is pressed : ");

void loop(){
  if(x == 1){
     //confirmation button was pressed.....DIM the LED
1 Like

Of course this is possible!

I’ll try to write up some pseudo code (which means it probably won’t compile, but it’s more of an idea which you can make into real code)

int confirmed = 0; // this sets the confirmation flag on or off

  if (confirmed) // Basically, this is shorthand for: if(confirmed == 1)
    int value = param.asInt();       // This get the value you set from the slider attached to virtual pin 1
    analogWrite(ledPin, value);    // this dims the led to the specified value

  confirmed == param.asInt();  // Set confirmed parameter from button attached to virtual pin 2

This should do the trick more or less.

1 Like

Thank you very much Lichtsignaal. Your idea worked like a charm.

Kind regards, Emi.

1 Like