PROJECT 5 – RC SERVO MOTOR POSITION

Nowadays, most hobbyist like to use RC servo motor to control their robot or others than that which need a precise position while a cheapest price. For this project, we are going to discover how to control 2 RC servo motor together using Arduino Duemilanove with Arduino Input Shield.

PROJECT 5

RC SERVO MOTOR POSITION

Back to Project 4                                                                                                     Go to Project 6

Nowadays, most hobbyist like to use RC servo motor to control their robot or others than that which need a precise position while a cheapest price. For this project, we are going to discover how to control 2 RC servo motor together using Arduino Duemilanove with Arduino Input Shield.

———————————————————————————————————————————————————-

COMPONENT NEEDED

———————————————————————————————————————————————————-

BREADBOARD
RC SERVO MOTOR
ARDUINO INPUT SHIELD
JUMPER WIRE

———————————————————————————————————————————————————-

CONNECTION

———————————————————————————————————————————————————-
Servo motors have three wires: power, ground, and signal. The power wire is typically RED, and should be connected to the 5V pin on the Arduino board. The ground wire is typically BLACK or BROWN and should be connected to a GND pin on the Arduino board. The signal pin is typically YELLOW, ORANGE or WHITE and should be connected to adigital pin 6 on the Arduino board.

Note servos draw considerable power, so if you need to drive more than one or two, you’ll probably need to power them from a separate supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together.

———————————————————————————————————————————————————-

ADDITIONAL INFORMATION

———————————————————————————————————————————————————-
ARDUINO RC SERVO LIBRARY
This library allows an Arduino board to control RC (hobby) servo motors. Servos have integrated gears and a shaft that can precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds. The Servo library supports up to 12 motors on most Arduino boards.

WIRE CONNECTION

Above are the picture showing that the different colour of wire using in different brand of servo motor. For more information, please refer to this servo wiring information.

HOW RC SERVO WORK
To control the RC servo position, we have to send a 20ms plus to the RC servo with a 0.5ms to 2.5ms pulse width to determine the servo position such as the figure showing below. For detail, please refer to this RC servo datasheet.

———————————————————————————————————————————————————-

CODE OVERVIEW

———————————————————————————————————————————————————-

Servo servo1;
Define the servo name as servo1.

Const int joy_pushbutton = 5;
Set the joy_pushbutton as pin 5 and also as the constant value.

Int val;
Define and store the value of RC servo motor.

Int mode = 1;
Define and store number 1 inside at the beginning.

Int current_joy_mode;
Define and store the mode of the joystick.

servo1.attach(6);
Define that the servo1 are attach to the digital pin-6.

val = map(val, 0 , 1023, 0, 179);
Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.

servo1.write(val);
Apply the value from ‘val’ to the servo1 which contain of any number within 0 to 179.

break;
Function to break out from the current loop.

for (val = 0; val < 180; val +=1)
Make the val increase 1 each step from 0 to 179.

mode = current_joy_mode;
Restore back to mode of he joystick whether in mode 1 or 2.

if ((digitalRead(joy_pushbutton)) == LOW)
Check if the joystick pushbutton is press.

while((digitalRead(joy_pushbutton)) == LOW);
Wait for debounce if the button is still pressing.

current_joy_mode = mode;
Store the current joystick mode.

Back to Project 4                                                                                                    Go to Project 6

———————————————————————————————————————————————————-

ATTACHMENT

1. P5 User Manual.pdf
2. Project_5_code.zip

BUY

1 thought on “PROJECT 5 – RC SERVO MOTOR POSITION”

  1. I REQUIRE A SERVO FOR A R/C BOAT USING 2/4 GHZ R/C BUT I DO REQUIRE A SERVO THAT WILL TURN 120 DEGREES 60 DEGREES EACH WAY.. THANK YOU..

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Control Stepper Motor 28BYJ-48 Using TTGO T-Display ESP32
Smart Dustbin
Interface LSM9DS1 9DOF IMU With TTGO T-Display ESP32
Send and Receive SMS Using TTGO ESP32 SIM800L
Getting Started With ProjekIoT.com Using Raspberry Pi
Scroll to Top