Devices & Components
LilyPad LED Green (5pcs)
NodeMCU ESP8266
Hardware & Tools
iPhone
Software & Tools
Blynk
Arduino IDE
Project description
Code
Controlling LED linked to ESP8266 with Blynk App On mobile phone
cpp
Blynk button widget controlls the led
1#define BLYNK_TEMPLATE_ID "TMPL4auv4TEh5" 2#define BLYNK_TEMPLATE_NAME "LEDcontrol" 3#define BLYNK_AUTH_TOKEN "JSNDzCPaWyAyop0q1R_6Nn9oVco717HY" 4 5#include <ESP8266WiFi.h> 6#include <BlynkSimpleEsp8266.h> 7 8char ssid[] = "******"; 9char pass[] = "******"; 10 11const int ledPin = D2; // Pin D2 (GPIO 4) 12 13BLYNK_WRITE(V0) // This function is triggered when Virtual Pin V1 changes 14{ 15 int value = param.asInt(); // Get the value from the Blynk app (0 or 1) 16 digitalWrite(ledPin, value); // Set the LED pin to HIGH or LOW 17} 18 19void setup() { 20 pinMode(ledPin, OUTPUT); 21 digitalWrite(ledPin, LOW); // Ensure LED is OFF initially 22 23 Serial.begin(9600); 24 Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass); 25} 26 27void loop() { 28 Blynk.run(); 29}
Comments
Only logged in users can leave comments