Andrewf1
Published © GPL3+

Smart Christmas Tree with ESP

A smart Christmas tree controlled by your smartphone using Blynk and ESP8266.

BeginnerFull instructions provided2 hours2,116
Smart Christmas Tree with ESP

Things used in this project

Hardware components

NodeMcu Lolin
×1
4-channel relay module
×1
5V DC power supply
×1

Software apps and online services

Arduino IDE
Arduino IDE
Blynk
Blynk

Story

Read more

Schematics

Chrismas tree scheme

This is scheme for christmas tree project

Code

Chrismas tree

Arduino
This is code for smart Christmas tree project.
#define BLYNK_PRINT Serial 
#include <ESP8266WiFi.h> 
#include <BlynkSimpleEsp8266.h> 

// You should get Auth Token in the Blynk App. 
// Go to the Project Settings (nut icon). 
char auth[] = "YourAuthToken"; 

// Your WiFi credentials. 
// Set password to "" for open networks. 
char ssid[] = "YourNetworkName"; 
char pass[] = "YourPassword"; 

bool automatic=false; 

void setup(){ 
 pinMode(5,OUTPUT); 
 pinMode(4,OUTPUT); 
 pinMode(0,OUTPUT); 
 pinMode(2,OUTPUT); 
 
 Serial.begin(9600); 

 Blynk.begin(auth, ssid, pass); 
} 

void loop(){ 
 
 if(automatic){                 //Automatic animation 
    digitalWrite(5,HIGH); 
    digitalWrite(4,LOW); 
    digitalWrite(2,LOW); 
    digitalWrite(0,LOW); 
    delay(1000); 
    digitalWrite(5,LOW); 
    digitalWrite(4,HIGH); 
    delay(1000); 
    digitalWrite(4,LOW); 
    digitalWrite(0,HIGH); 
    delay(1000); 
    digitalWrite(0,LOW); 
    digitalWrite(2,HIGH); 
    delay(1000);      
  } 
 Blynk.run(); 
} 

BLYNK_WRITE(V1){ 
 int pinValue = param.asInt();  
 if(pinvalue==1){ 
   digitalWrite(5,HIGH);   
 }else{ 
   digitalWrite(5, LOW); 
 } 
} 

BLYNK_WRITE(V2){ 
 int pinValue = param.asInt();  
 if(pinvalue==1){ 
   digitalWrite(4,HIGH);   
 }else{ 
   digitalWrite(4,LOW);  
 } 
} 

BLYNK_WRITE(V3){ 
 int pinValue = param.asInt();  
 if(pinvalue==1){ 
   digitalWrite(0,HIGH);   
 }else{ 
   digitalWrite(0,LOW);  
 } 
} 

BLYNK_WRITE(V4){ 
 int pinValue = param.asInt();  
 if(pinvalue==1){ 
   digitalWrite(2,HIGH);   
 }else{ 
   digitalWrite(2,LOW);  
 } 
} 

BLYNK_WRITE(V5){ 
 int pinValue = param.asInt();  
 if(pinvalue==1){ 
   automatic=true; 
 }else{ 
   automatic=false; 
 } 
} 

Credits

Andrewf1

Andrewf1

7 projects • 17 followers

Comments