Smart Home Automation System: Control LEDs with NodeMCU and Blynk App

home automation

Circuit Diagram:

home automation circuit

Code:

#define BLYNK_TEMPLATE_ID "*****************" // paste the copied details from blynk cloud
#define BLYNK_TEMPLATE_NAME "***************"
#define BLYNK_AUTH_TOKEN "******************"

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int led1=14;
int led2=15;

char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "******"; //your hotspot name
char pass[] = "******"; //your hotspot password name

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);

}

void loop() {
  Blynk.run();
}

BLYNK_WRITE(V1){
  int pinValue = param.asInt(); // assigning incoming value from pin V0 to a variable
  digitalWrite(led1,pinValue);
}

BLYNK_WRITE(V2){
  int pinValue = param.asInt(); // assigning incoming value from pin V0 to a variable
  digitalWrite(led2,pinValue);
}