#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "xxxxxx"
#define BLYNK_TEMPLATE_NAME "poject3"
#define BLYNK_AUTH_TOKEN "YMxlOlVaEev2c9Kl46RSQhvQI7tV-zAU"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
String inputString;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(19, OUTPUT);
pinMode(18, OUTPUT);
pinMode(5, OUTPUT);
Blynk.begin(auth, ssid, pass, "iot.serangkota.go.id", 8080);
}
void loop() {
Blynk.run();
// put your main code here, to run repeatedly:
}
BLYNK_WRITE (V10) {
inputString = param.asStr(); // Menyimpan string dari widget ke dalam variabel
Serial.print("Nilai dari Blynk: ");
Serial.println(inputString);
}
BLYNK_WRITE (V1) {
Serial.println(param.asInt());
if (param.asInt() == 1) {
digitalWrite(19, HIGH);
} else {
digitalWrite(19, LOW);
}
}
BLYNK_WRITE (V2) {
Serial.println(param.asFloat());
if (param.asInt() == 1) {
digitalWrite(18, HIGH);
} else {
digitalWrite(18, LOW);
}
}
BLYNK_WRITE (V3) {
if (param.asInt() == 1) {
digitalWrite(5, HIGH);
} else {
digitalWrite(5, LOW);
}
}