5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10

ARDUBLOCK Project 10: Servo Motor Control

Posted by Fiona Su on

Servomotor is a commonly used positional-servo actuator.
In this project, we use graphical programming . First , read out analog value controlled by adjustable potentiometer module, ranging from 0 to 1023. Then, map the value to 0-180. Finally, set the mapped value as angle of motor rotation.
Materials Required:
  • 1. KEYESTUDIO UNO Control Board *1
  • 2. V5 Sensor Shield*1
  • 3. Adjustable Potentiometer*1
  • 4. Micro Servo*1
  • 5. Female to Female Dupont Line*3

Connection Diagram:
Note: do not use the USB port for power supply because the current it needs is more than 500ma,it may lead to USB port burnt out. We recommend external power supply.



After wiring, we can start programming.


Click “download to Arduino” to see the codes in Arduino interface.
Sample Code:

#include <Servo.h>
int _ABVAR_1_val = 0 ;
int _ABVAR_2_servo = 0 ;
Servo servo_pin_9;

void setup()

void loop()
  _ABVAR_1_val = analogRead(0) ;
  _ABVAR_2_servo = map ( _ABVAR_1_val , 0 , 1023 , 0 , 180 )  ;
  servo_pin_9.write( _ABVAR_2_servo );

Put the program into the development, and we can use potentiometer to control servomotor.
Note:place Servo folder into the compiler of \Arduino\libraries. Otherwise, you can’t compile. Just like this D:\Program Files\Arduino\libraries
Servo folder downloading address:

All Projects

Buy it >> ARDUBLOCK Graphical Programming Starter Kit for Arduino


Leave a comment

Please note, comments must be approved before they are published