Esp8266 Servo LightSwitch Neutral?

Would a delay in the code work to reset my servo controlled light switch back to a neutral position? Right now I have a Switch/Button in the Blynk app set to various values to switch the light switch at home to on or off. I want to have it reset to a neutral position after the button is switched to on or off.

#define BLYNK_PRINT Serial

#include <ESP8266WiFi.h>

#include <BlynkSimpleEsp8266.h>

#include <Servo.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";

Servo servo;


#these two lines are my edits delay(500);


void setup() {

// Debug console Serial.begin(115200);

Blynk.begin(auth, ssid, pass);

// You can also specify server:

//Blynk.begin(auth, ssid, pass, "", 8442);

//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);

servo.attach(15); // 15 means D8 pin of ESP8266


void loop()

{; // You can inject your own code or combine it with other sketches.


1 Like

Yes, a simple timeout delay that activates/deactivates your lights and then. after a short delay, moves the servo to neutral will work fine.

BlynkTimer timer;  // Place in the beginning of the code with the defines

timer.setTimeout(2000L, ServoNeutral);  // In two seconds, Run the void ServoNeutral() routine.

void ServoNeutral() {
};  // Place in the main void loop
1 Like

Thank you so much! It works and centers back so I can manually control it without the servo fighting me haha.

1 Like

The engineering part is :ok_hand::ok_hand::ok_hand: