Hi all i am trying to make this unit turn on V1 led when D9 is High and V2 led when D7 is High & have a V7 button to turn on D7 from the app i have the temp side working. thank you
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>
#include <DHT.h>
char auth[] = “***************************”;
int redLed = 9;
int greenLed = 8;
int over = 7;
float time;
#define DHTPIN 2 // What digital pin we’re connected to
WidgetLED led1(V1);
WidgetLED led2(V2);
// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
SimpleTimer timer;
void sendSensor()
{
float h = dht.readHumidity();
float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h) || isnan(t)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}
// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(V5, h);
Blynk.virtualWrite(V6, t);
}
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth);
BLYNK_READ(PIN_UPTIME);
dht.begin();
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(over, OUTPUT);
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
void LedWidget()
{
if (led1.getValue()) {
led1.on();
Serial.println(“LED on V1: on”);
} else {
led1.off();
Serial.println(“LED on V1: off”);
}
if (led2.getValue()) {
led2.on();
Serial.println(“LED on V2: on”);
} else {
led2.off();
Serial.println(“LED on V2: off”);
}
}
void loop()
{
Blynk.run(); // Initiates Blynk
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println(“Failed to read from DHT”);
} else {
Serial.print(“Time: “);
time = millis()/1000;
Serial.print(time);
Serial.print(” secs\t”);
Serial.print(“Humidity: “);
Serial.print(h);
Serial.print(” %\t”);
Serial.print(“Temperature: “);
Serial.print(t);
Serial.println(” *C”);
}
// Turn red LED on and green LED off if the temperature is 25 degrees or more.
// Turn green LED on and red LED off if the temperature is less than 25 degrees.
if (t >= 25) {
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
}
else {
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
}
// Wait 5 seconds before starting the next reading.
delay(5000);
timer.run(); // Initiates SimpleTimer
}