Previous                                    Tutorial                                  Tutorial


In this lesson, we will show how to use the Osoyoo Yun IoT Kit to control a SG90 servo remotely.




Build the circuit as below:

Mega2560+Yun Shield SG90 Servo
D2 Signal

Code Program

After above operations are completed, make sure that the Yun Shield is on the same network with the computer. Open the Arduino IDE and choose corresponding board type and port type for you project. Then load up the following sketch onto your Arduino.

#define BLYNK_PRINT Console
#include "Console.h"
#include "Bridge.h"
#include "Console.h"
#include "BlynkSimpleYun.h"
#include "Servo.h"
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Your Auth Token";

Servo myservo;


void setup()
  // You can also specify server:
  //Blynk.begin(auth, "", 8442);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8442);

  myservo.write(0);//back to 0 degrees 
  while (!Console);{}

void loop()

Add a Widget

In this example, you need to add a slider widget. Tap anywhere on the canvas to open the widget box. All the available widgets are located here. Now pick the slider widget.

Similar to potentiometer. Allows to send values between MIN and MAX.


Slider widget attached to V3 (0~180), value: Servo

Running Result

After you finished all above operations, open the Serial Monitor, then open the Blynk APP,  slide the slider. This will switch you from EDIT mode to PLAY mode where you can interact with the hardware. While in PLAY mode, you won’t be able to drag or set up new widgets, press STOP and get back to EDIT mode.

Now, you'll see the servo turning with the slide.!

Previous                                    Tutorial                                  Tutorial