Adafruit 'the thing' esp8266 servo control

I wanted to control a robot using blynk with adafruit "the thing " board. I’m new at using blynk and was unable to find ‘simple’ project to copy. Finally figured it out. I’m starting by controlling a continuous rotating servo. I have two buttons in ‘switch’ mode. When i push to ‘on’ position on V1[virtual pin] the servo rotates ccw, when i push to off position, it stops. On V2 button, it goes cw when pushed to on position. Powering servo with external p/s to avoid burning up esp8266! Works great. Using servo.h to make it easy.

#define BLYNK_PRINT Serial    // Comment this out to disable 
//prints and save space
#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).
Servo servo;
Servo servo2;
char auth[] = " "; // insert code here.

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, "xxxxxx", "yyyyyy");
  servo.attach(0); //pin 0
  // servo2.attach(4); 
}


BLYNK_WRITE(V1)// 
{
   if (param.asInt()){       
        servo.writeMicroseconds(1000);//ccw
        
    } else {
        servo.writeMicroseconds(1500);//stop
    }

}

 BLYNK_WRITE(V2)
{
   if (param.asInt()){    //button on.   
        servo.writeMicroseconds(2000);//cw
    
    } else { //button off.
        servo.writeMicroseconds(1500);//stop
    }
}

void loop()
{
  Blynk.run();

  
}
1 Like

Code snippet should be formatted. Edit your post!

Wrap the code by adding 3 Backtick: ``` symbols:

Example:

 ``` cpp <--put 3 backticks BEFORE your code starts  (cpp means C++ language) 

   //Put your code here
   //..................
   //..................

 ``` <--insert 3 backticks AFTER your code

**This makes your code readable and with highlighted syntax, like this:**
//comment goes here 
void helloWorld() { 
   String message =  "hello" + "world"; 
}

got it. Thanks for pointing that out. New at this:slight_smile:

1 Like