Tv lift made with Blynk

Here’s a link to a video of a tv lift I made using a 600mm electric actuator from eBay,a standalone esp8266-12,a 2 channel relay and of course the amazing Blynk. The code is very crude with lots of naughty delays :flushed:(I’m very new to C maybe if I post it someone could clean it up to be Blynk friendly​:thinking:)

7 Likes

A W E S O M E! :clap:

Are you using stepper motor? How big is the load?


I hacked into the control box and found 3 wires(live,up,down) and used relays to make the circuit to lift/drop. By load assume you mean weight? If so I’m not sure but it’s a 42" tv so I’d guess about 10-15kg

Ah, got it. I thought you’ve build the lift. Anyway, looks very sci-fi :space_invader:

pretty cool! i have always loved these lifts, and have wanted to build one for a while. I would be interested in the code and may be able to help clean it up a bit . I am also new to all this, but converted my first effort into optimized code by using SimpleTimer and moving everything into functions.

Thanks,you should build one!
I’ve advanced a little bit with my coding since I first made the tv lift and here’s the latest version of code.
I don’t know if it’s my coding or the app but the app forgets the widget led states if app gets stopped and my other devices running Blynk don’t update the widget led states either:confused:

 int relaypin=12;
int relaypin2=14;
int power=16;

int tvupflag=3;
//int tvdownflag=0;
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // stores the time from when lift/drop 
unsigned long previousMillis2 = 0;        // stores the time from when lift/drop 
// constants won't change :
const long interval = 15000;           // length of time to lift tv (milliseconds)


#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>



// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "";
WidgetLED led1(V3);
WidgetLED led2(V4);
WidgetLED led3(V2);

void setup()
{
  
    pinMode(relaypin, OUTPUT);
 pinMode(relaypin2, OUTPUT);
  
 pinMode(power, OUTPUT);
 // Set console baud rate
   Serial.begin(115200);
  Serial.print("GO");
  
  
  
   Blynk.begin(auth,  "fbimainframe", "myob");
  while (Blynk.connect() == false) {
    // Wait until connected
  }
  Serial.print("GO");
  
//


  // Notify immediately on startup
Blynk.notify("Device started");
Blynk.run();
}

void liftup()
{
   
  unsigned long currentMillis = millis();


  if (currentMillis - previousMillis <= interval) {
   digitalWrite(relaypin2, HIGH);// turn on the relay to lift
    digitalWrite(power, LOW);led2.off();
  
led3.on();// TURN ON POWER LED
  }
  else{
  // save the last time you came here 
    previousMillis = currentMillis;
     digitalWrite(relaypin2, LOW);//turn off lift relay
     tvupflag=3;// tell main loop not to come here
     led1.on();
    
 }
}
     void liftdown(){
  
  unsigned long currentMillis= millis();


  if (currentMillis - previousMillis2 <= interval) {
   digitalWrite(relaypin, HIGH);// turn on the relay to lift
    digitalWrite(power, HIGH);led1.off();//led2.setValue(value);//turn off power relay,down led on,up led off
  
led3.off(); 
  }
  else{
   // save the last time you came here 

   
    previousMillis2 = currentMillis;
     digitalWrite(relaypin, LOW);//turn off lift relay
     tvupflag=3;// tell main loop not to come here
     led2.on();

  }
}
void loop()
{
 
  //@@@@@@@@@@@@@@@@ LIFT TV ? @@@@@@@@@@@@@@@@@@@@@@@@@
  if (tvupflag==1){

   liftup();
    }
     //@@@@@@@@@@@@@@@@ DROP TV ? @@@@@@@@@@@@@@@@@@@@@@@@@
  if (tvupflag==0){
    liftdown();
  }
   
    
    
   
  Blynk.run();
  
  
}
BLYNK_WRITE(V1)
{
 
  BLYNK_LOG("Got a value: %s", param.asStr());
 
  int i = param.asInt();
  
  if (i==1 && tvupflag !=1){
    Serial.println("DROP ME");)
    tvupflag=0;//tell main program to drop tv
    
  }
  
}
BLYNK_WRITE(V0)
{
  BLYNK_LOG("Got a value: %s", param.asStr());
  
  int i = param.asInt();
  if (i==1 && tvupflag !=0){
    Serial.println("LIFT ME");
   
    tvupflag=1;//tell main program to lift tv
    }
  
  
}