// 1. PASTE YOUR BLYNK CREDENTIALS HERE (From the Blynk Web Console)
#define BLYNK_TEMPLATE_ID "TMPL6iX2VkORB"
#define BLYNK_TEMPLATE_NAME "LED Control"
#define BLYNK_AUTH_TOKEN "iYj0bSjo5xg7BKNp4TjXPi4PXQawzhJI"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// 2. ENTER YOUR WIFI NETWORK DETAILS
char ssid[] = "Aku Cinta Rupiah";
char pass[] = "0351895059";
// Built-in LED pin on Wemos D1 Mini (Connected to D4 / GPIO2)
const int ledPin = LED_BUILTIN;
// This function executes whenever the button on the Blynk app changes state
// V0 is the Virtual Pin assigned to the Button Widget in Blynk
BLYNK_WRITE(V0) {
int buttonValue = param.asInt(); // Reads button state (1 for ON, 0 for OFF)
// NOTE: The Built-in LED on Wemos is Active-LOW
// (It turns ON with LOW/0, and turns OFF with HIGH/1)
if (buttonValue == 1) {
digitalWrite(ledPin, LOW); // Turn ON
Serial.println("LED turned ON");
} else {
digitalWrite(ledPin, HIGH); // Turn OFF
Serial.println("LED turned OFF");
}
}
void setup() {
// Start Serial Monitor for debugging
Serial.begin(115200);
// Configure the built-in LED pin
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH); // Default state: LED OFF
// Connect Wemos to WiFi and the Blynk Cloud Server
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop() {
Blynk.run(); // Maintains active communication with the Blynk server
}