Hi everyone I’m a new entusiast user of Blynk app, I trying to use the value that setup with a slider widget form blynk app reading the virtual port V1, I’m using the example code and I can print the value of the slider in the serial monitor and also I define a variable for calculate the ON time even can use an IF to switch on a led in the pin 2 but, what I want to do is that the value from slider sets the ON time the led and then the led switch to off, taking the OFF time from another slider from the app. Then I want that happens continuosly by all day. The led have to switch from ON to OFF allways, and the times ON and OFF had to be sets from the sliders from the app.
My problem is that setup the ON time with the slider, then led switch ON but the led never switch to OFF when the ON time run out. Then the app fails and the arduino too.
Please help!!!
Code:
/*************************************************************
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
You can use this sketch as a debug tool that prints all incoming values
sent by a widget connected to a Virtual Pin 1 in the Blynk App.
App project setup:
Slider widget (0...100) on V1
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "c046b3f28xxxxxxxxxd4d2cfb74d";
#define W5100_CS 10
#define SDCARD_CS 4
int WaveGen1=2;
int TWaveGen1=0;
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
// You can also use:
// String i = param.asStr();
// double d = param.asDouble();
Serial.print("V1 Slider value is: ");
Serial.println(pinValue);
TWaveGen1=pinValue*1000;
Serial.print("Tiempo de enc: ");
Serial.println(TWaveGen1);
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
pinMode(WaveGen1,OUTPUT);
Blynk.begin(auth);
}
void loop()
{
Blynk.run();
if (TWaveGen1>0){
digitalWrite(WaveGen1,HIGH);
delay(TWaveGen1);
digitalWrite(WaveGen1,LOW);
}
}