Rookie needs help!!
Does someone know how to modify the widget led-sketch from sketch builder so, that it starts with an input.
For exampe if button V1 is pressed, it will start do fade up until its highest, than again down until its lowest and so on. Essentially I want know only where I can put the condition to start it.
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken";
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
WidgetLED led2(V2);
BlynkTimer timer;
void fadeLedWidget()
{
static int value = 0;
static int delta = 30;
value += delta;
if (value > 255 || value < 0) {
delta = -delta;
} else {
Serial.print("LED on V2: ");
Serial.println(value);
led2.setValue(value);
}
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(300L, fadeLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
}
Normally I program everything so, that I call every function from an other function but here it does not works, because the command to fade up and to fade down become called usually every 100ms from the timer.
How I can say:
{
int button = param.asInt();
if (button == 1) {
////////////////////////////////
Only if these condition above is right, the led should start to fade up and down
////////////////////////////////
}
Would be very nice, if someone could help a rookie like me