How to control a Servo using Arduino

Arduino control a Servo

In this one, servo is programmed to be controlled by two buttons, one turns servo to the left and the other one turns it to the right. When the servo is turning, corresponding LED will be switched on to indicate the operation.

Result:Arduino control a Servo

Because Arduino has built-in library for controlling servo, which makes servo a really easy kit to use. In this project, I will be using a servo to turn the IR sensor around constantly.
This is the circuit Diagram:
This is the code:
// Oscar’s Project
//
// There are 2 input buttons (turn left and right), when button is pressed, the servo turns and corresponding LED is lit up.

#include

Servo myservo;  // create servo object to control a servo
// a maximum of eight servo objects can be created

Servo Schematic

Leave a Comment

Your email address will not be published. Required fields are marked *