Hello,
i am trying to put a pin high for a time witch is controlled by a slider value but the problem is that the value is not transfered to the loop part.
if i define a value like 5000 it works fine but if i try to set the time with the slider it doesnt work.
Thank you for your help.
#define BLYNK_PRINT Serial1
#include <BlynkSimpleStream.h>
char auth[] = "d1d76ee...........................fcfcf22e";
int test = 5000;
int Button1;
int Slider1;
int Slider2;
int Display = Slider1 + Slider2; // sum of slider 1 and slider 2
int zeit = Slider1;
unsigned long previousMillis = 0;
void setup()
{
Serial1.begin(9600);
Serial.begin(9600);
Blynk.begin(Serial, auth);
Blynk.syncVirtual(V1);
Blynk.syncVirtual(V2);
Blynk.syncVirtual(V6);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop()
{
Blynk.run();
unsigned long currentMillis = millis();
if ((Display <= 2500000 && Button1 == 1) && (unsigned long)(currentMillis - previousMillis) <= zeit)
{
digitalWrite(7, HIGH);
}
if ((unsigned long)(currentMillis - previousMillis) >= (zeit + 1))
{
digitalWrite(7,LOW);
Button1 = 0;
}
if ((unsigned long)(currentMillis - previousMillis) >= (zeit + 2))
{previousMillis = currentMillis;
}
}
BLYNK_WRITE(V1)
{
Slider1 = param.asInt();
Display = Slider1 + Slider2;
if(Slider2 != 0){ // just a hack for initial boot when 2nd slider doesn't yet have a value
Blynk.virtualWrite(V3, Display);
Blynk.virtualWrite(V5, Slider1);
}
}
BLYNK_WRITE(V2) {
Slider2 = param.asInt();
Display = Slider1 + Slider2;
Blynk.virtualWrite(V4, Slider2);
Blynk.virtualWrite(V3, Display);
}
BLYNK_WRITE(V6) {
Button1 = param.asInt();
}