Servo Sweep using Arduino IDE

Controlling Servo Motor
About This Tutorial
In this tutorial we will sweeps the shaft of a RC servo motor back and forth across 180 degrees using Arduino IDE.
Tutorial Info

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1
Micro Servo Motor with Accessories1

Introduction

In this tutorial we will sweeps the shaft of a RC servo motor back and forth across 180 degrees.

Servo Sweep using evive and Arduino IDE

Circuit Diagram

In the following example, I will be showing you how to control servo through channel 1. Given below is the circuit diagram:

A Servo pin has three wires (Order to be connected in evive, left to right)

  • Brown wire: GND
  • Red wire: VCC
  • Orange wire: Signal
Caution: Power evive using a 12V 2A power adapter for smooth functioning of servo motor. The VVR (Variable voltage) should be close to 6V.

Logic Diagram

Angle at the start of the program should be 0 degrees. Then it should increase until it reasches 180 degree angle, then it should decrease until it reaches 0 degree angle.

Code

[pastacode lang=”c” manual=”%23include%20%3Cservo.h%3E%0A%0Adouble%20Angle%3B%0AServo%20servo_44%3B%0A%0Avoid%20setup()%7B%0A%20Angle%20%3D%200%3B%0A%20servo_44.attach(44)%3B%20%2F%2F%20init%20pin%0A%7D%0A%0Avoid%20loop()%7B%0A%20while(!(((Angle)%3D%3D(180))))%0A%20%7B%0A%20Angle%20%2B%3D%205%3B%0A%20servo_44.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%20%7D%0A%20while(!(((Angle)%3D%3D(0))))%0A%20%7B%0A%20Angle%20%2B%3D%20-5%3B%0A%20servo_44.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%20%7D%0A%7D” message=”” highlight=”” provider=”manual”/]

Servo Sweep using Arduino Uno

Arduino uno has 6 PWM pins: 3, 5, 6, 9, 10, and 11 which provide 8-bit PWM output with the analogWrite() function.

We will controlling serov using Pin 3.

Circuit Diagram

A Servo pin has three wires (Order to be connected in evive, left to right)

  • Brown wire: GND
  • Red wire: VCC
  • Orange wire: Signal

Servo Angle

Caution: Power servos using a 6V 2A power adapter for smooth functioning of servo motor.

Code

[pastacode lang=”c” manual=”%23include%20%3Cservo.h%3E%0A%0Adouble%20Angle%3B%0AServo%20servo_3%3B%0A%0Avoid%20setup()%7B%0A%20Angle%20%3D%200%3B%0A%20servo_3.attach(3)%3B%20%2F%2F%20init%20pin%0A%20servo_3.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%7D%0A%0Avoid%20loop()%7B%0A%20while(!(((Angle)%3D%3D(180))))%0A%20%7B%0A%20Angle%20%2B%3D%205%3B%0A%20servo_3.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%20delay(20)%3B%0A%20%7D%0A%20while(!(((Angle)%3D%3D(0))))%0A%20%7B%0A%20Angle%20%2B%3D%20-5%3B%0A%20servo_3.write(Angle)%3B%20%2F%2F%20write%20to%20servo%0A%20delay(20)%3B%0A%20%7D%0A%7D” message=”” highlight=”” provider=”manual”/]

 

Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Projects & Tutorials
evive-Plug-and-Play-Part-1
evive – Plug and Play: Part 1
In this tutorial, we are going to give you a hands-on experience of evive’s plug and play interface through activities for controlling a DC motor, a servo motor, understanding the inbuilt touch sensors of evive.
controlling gripper
How to interface Servo Motor with Arduino IDE
This tutorial discusses what are servo motors, how to control them, and how to interface them with Arduino IDE using motor control units in evive with the help of an Arduino IDE sketch.
All articles loaded
No more articles to load
Featured Projects
All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart