#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxx";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ssidxxx";
char pass[] = "passxxx";
WidgetLED led1(V4);
WidgetLED led2(V3);
int sensor1 = 14;
int sensor2 = 27;
int sensorPin = 2; // Input pin for the Flame Sensor
int sensorValue = 1; // Variable to store the value coming from the flame sensor
int relay1 = 23;
int relay2 = 22; //buat buzzer
void setup()
{
// Debug console
pinMode(sensor2,INPUT);
pinMode(sensor1,INPUT);
pinMode(relay1, OUTPUT);
pinMode(relay1, HIGH);
pinMode(relay2, OUTPUT);
pinMode(relay2, HIGH);
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, "blynk-cloud.com",8080);
pinMode(2, INPUT);
while (Blynk.connect() == false) {
}
}
void loop()
{
Blynk.run();
sensorValue = digitalRead(sensorPin);
if (sensorValue == 1) {
Blynk.notify("Saya hausssss");
}
int sensorval1 = digitalRead(sensor1);
int sensorval2 = digitalRead(sensor2);
Serial.println(sensorval1);
Serial.println(sensorval2);
delay(1000);
if (sensorval1 == 1)
{
led1.on();
}
if (sensorval2 == 1)
{
led2.on();
}
if (sensorval1 == 0)
{
led1.off();
}
if (sensorval2 == 0)
{
led2.off();
}
}
Comments