0% found this document useful (0 votes)
20 views5 pages

Robotics Notes

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

Servo Motors

An Arduino servo motor refers to a type of motor commonly used with Arduino microcontrollers for
precise control of position and movement. Servo motors are designed to provide accurate angular or
linear displacement based on the electrical signals they receive.

The key features of Arduino servo motors are:


 Position Control: Servo motors are primarily used for position control. They can rotate to
specific angles or move to precise positions, allowing for controlled and repeatable movements.
 Feedback Mechanism: Servo motors are equipped with built-in position feedback mechanisms,
such as potentiometers or encoders. These mechanisms provide information about the motor's
current position, allowing for closed-loop control.
 PWM Control: Servo motors are typically controlled using Pulse Width Modulation (PWM)
signals. The Arduino generates PWM signals that determine the motor's desired position or angle.
By varying the pulse width, the motor can be positioned to different angles within its range.
 Limited Rotation: Unlike continuous rotation motors, servo motors have a limited range of
rotation, typically between 0 and 180 degrees. This limited range makes them well- suited for
applications that require precise control over specific angles.
 Torque Control: Servo motors provide torque proportional to the electrical signals they receive.
This feature allows them to exert a controlled amount of force or resistance, making them useful
in applications where force control is required.
 Compact and Lightweight: Servo motors are often compact and lightweight, making them
suitable for various applications, including robotics, RC vehicles, automation, and other projects
where space and weight constraints are a consideration.
 Easy Interfacing: Servo motors can be easily interfaced with Arduino microcontrollers using just
a few wires. They usually require power supply connections, ground connections, and a signal
wire to receive the PWM control signal

 Arduino libraries and example codes are available to simplify the programming and control of
servo motors. These libraries abstract the low-level details of generating PWM signals, allowing
users to easily set the desired position or angle of the servo motor.

Circuit
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 ground pin on the Arduino board. The signal pin is typically yellow, orange or white and
should be connected to a digital pin on the Arduino board. Note that 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.

Knob Circuit
For the Knob example, wire the potentiometer so that its two outer pins are connected to power (+5V) and
ground, and its middle pin is connected to A0 on the board. Then, connect the servo motor to +5V, GND
and pin 9.
Controlling a servo position using a potentiometer (variable resistor).
Sweep Circuit
For the Sweep example, connect the servo motor to +5V, GND and pin 9.
Sweeps the shaft of a RC servo motor back and forth across 180 degrees.

Ultrasonic Sensors
How Does an Ultrasonic Module Work?
• This module consists of two drums, one of which is an emitter that emits ultrasound and other is
receiver which receives the reflected ultrasound from the object.
• The emitter drum emits ultrasound when we trigger the module using the trigPin by sending a 10
microseconds high pulse.
•As soon as the ultrasound is emitted through the emitter the module makes the echoPin high.
•Emitted ultrasound travels forward till it gets reflected by object and then travels backward.
• The reflected ultrasound is detected by the receiver.
•When the reflected ultrasound is received by the receiver, echoPin is made low.
•Now we have the time take by the ultrasound to reach the object and again reach the source which is also
equal to the duration for which the echoPin was high.
•This time is stored in the microcontroller. Therefore travel time of ultrasound between just source to
object is half the time take to travel source-object-source we know that:

Code
First we define the pins that Trig and Echo are connected to.
const int trigPin = 9;
const int echoPin = 10;

Then we declare 2 floats, duration and distance, which will hold the length of the sound wave and how far
away the object is.
float duration, distance;

The float is one of the most important Arduino data type as it can store decimal numbers. This data type is
for floating-point numbers which are numbers with a decimal point. Floating-point numbers are often
used to approximate the analog and continuous values because they have greater resolution than integers
Sidt
pulseIn()
Returns the length of the pulse in microseconds or gives up and returns 0 if no complete pulse was
received within the timeout.

You might also like