Controlling The Camera Gimbal Using ESP8266 - Building Smart Drones With ESP8266 and Arduino
Controlling The Camera Gimbal Using ESP8266 - Building Smart Drones With ESP8266 and Arduino
1 Firstly, attach the servos to the bracket. Connect the servos to the ESP8266, as follows:
2 From the diagram, you can see that the servos are connected to the GPIO pins of the ESP8266. GPIO 0 and GPIO 2
or D3 and D4, respectively. Now you need to write code for our ESP8266 but, before that, open your Blynk app and
create a New Project :
3 Give your project a name and from Choose Device , select NodeMCU or ESP8266 , whichever you use for your
gimbal. Hit Create Project . Remember the authentication code of the project. The code will also be sent to your
email.
4 Next, swipe right to get the Widget Box and choose Slider :
5 Give your slider a name. I gave Servo 1 and Servo 2 for the two sliders we need:
6 Select a Virtual pin for each of the sliders. I chose V1 and V6 :
7 Your final look of the project will look like the following screenshot. You may change the color from the slider
properties:
Let's begin our coding to control the gimbal:
1 Fire up your Arduino IDE and add the following lines at the top of the sketch:
Copy
3 Now, declare the authentication code you got for your project and the Wi-Fi name and password for the connection,
as follows:
Copy
Copy
5 Inside the void setup() , we need to start the Blynk and then attach the servo pins:
Copy
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
s1.attach(0);
s2.attach(2);
Copy
BLYNK_WRITE(V1)
{
s1.write(param.asInt());
}
BLYNK_WRITE(V6)
{
s2.write(param.asInt());
}
Copy
Blynk.run();
8 Now, verify and upload the code after connecting the NodeMCU to the computer.
9 From your Blynk application, run the project. You will see your sliders, as follows:
( BACK
(/BOOK/HARDWARE_AND_CREATIVE/97817884…
(/BOOK/HARDWARE_AND_CREATIVE/97817884…
10 Now, if you move your sliders from left to right, you will see your servos will move 0 - 180 degrees.
You may get some resonances. So, I would suggest you use an LM1117 voltage regulator between the NodeMCU
and the battery or the power supply. Now, I have some home work for you. I want you to make a switch from the
Blynk and trigger the camera you will use in the drone using Blynk application.