LinkIt ONE Tutorial - Mini Servo


What We’re Doing

Servo motor (servo) is commonly used in small robots and other machines to control angular position. It is wrapped by a small gear box, and positioned by the timing control pulses. In this section we control the angular position of the mini servo with the help of potentiometer.

Things you need

  • LinkIt One x 1

  • Break board x 1

  • Slide Potentiometer 10kΩ x 1

  • Servo x 1




Please click on the button below to download the code for the kit:

You can unzip the file to the Examples folder of your Arduino IDE.

To access the demo code open:

File -> Examples -> Starter Kit for LinkIt -> Basic -> L7_Servo

#include <Servo.h>

Servo myservo;              // create servo object to control a servo
int potpin = A0;             // analog pin used to connect the potentiometer
int val;                    // variable to read the value from the analog pin

void setup()
    myservo.attach(9);                  // attaches the servo on pin 9 to the servo object

void loop() {
    val = analogRead(potpin);          // reads the value of the potentiometer (value between 0 and 1023)
    val = map(val, 0, 1023, 0, 179);   // scale it to use it with the servo (value between 0 and 180)
    myservo.write(val);                // sets the servo position according to the scaled value
    delay(15);                         // waits for the servo to get there


  • There are three pins in servos and they are color coded respective to their functionality yellow-analog port red – positive, dark brown – ground. So please make connections according to its functionality.

  • Ensure that 5v power supply is connected to the board.

Making it better

If the mini steering worked, we can adjust the speed of rotation by using a potentiometer. Upload the following code to produce different functionality.

To access the demo code open:

File -> Examples -> Starter Kit for LinkIt -> Extend_Lesson –> L7_Servo_Speed

More ideas

How do you control two servo motors simultaneously so that you can make a robot?


Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:

  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.

An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.

Happy hacking