top of page

#include <Wire.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

int LED1 = D4;
int RAINSENSOR = A0;
int sensorData;

char auth[] = "d11abab12e1741e9947e16a517923efe";
char ssid[] = "wasanfern";
char pass[] = "1234567890";

WidgetLCD lcd1(V0); // LCD บน Blynk
BlynkTimer timer; // Announcing the timer
WidgetLED LampBlynk(V2);
WidgetLED Lamp1Blynk(V3);
WidgetLED LED1Blynk(V1);

void setup()
{
  pinMode(RAINSENSOR, INPUT);
  pinMode(LED1, OUTPUT);
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
}

void loop(){
  
    if (0 == digitalRead(RAINSENSOR)) 
    {
     digitalWrite(LED1, HIGH);
     lcd1.clear(); 
     lcd1.print(1,0,"RAINING"); 
     lcd1.print(2,1,"Heavily!"); 
    } 
    else
    { 
     digitalWrite(LED1, LOW);
     lcd1.clear(); 
     lcd1.print(1,0,"NOT RAINING"); 
     lcd1.print(2,1,"Warning!"); 
     LampBlynk.off();
     Lamp1Blynk.on();
    }
      Blynk.run();
    timer.run(); 
}
 

bottom of page