/*
Blynk example
You should get Auth Token in the Blynk App.
You need to write the right wifiCredentials.
*/
/* Comment this out to disable prints and save space */
//Didapat dari web blynk could
#define BLYNK_TEMPLATE_ID "TMPLxbP-DtNd"
#define BLYNK_DEVICE_NAME "ESP32 Kontrol LED"
#define BLYNK_AUTH_TOKEN "cBxB2LT4AQHrZVtgkK8EG3QBTYz208Nn"
#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[] = BLYNK_AUTH_TOKEN;
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wokwi-GUEST"; //nama hotspot yang digunakan ESP32
char pass[] = ""; //password hotspot yang digunakan
BLYNK_WRITE(V0) //menggunakan V0 karena pada web blyk datastream menggunakan V0
{
int pinValue = param.asInt(); // menugaskan nilai yang masuk dari pin V1 ke variabel
if (pinValue == 1) //jika Blynk Could mengirim data 1
{
digitalWrite(4, HIGH); //maka, LED menyala. 4 = pin yang digunakan LED
}
else { // jika tidak
digitalWrite(4, LOW); //maka, LED tidak menyala
}
// process received value
}
void setup()
{
// Debug console
Serial.begin(115200);
pinMode(4, OUTPUT); //inisialisasi Pin 4 sebagai Output
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}
void loop()
{
Blynk.run();
}