One-sentence summary
A robot arm is made of servos, each controlled by an angle; when we change those angles in the right order, the arm can pick up an object and place it somewhere else.
Why it matters
Most of the machines that move boxes in factories or place tubes in laboratories are robot arms. They may look complicated, but the core idea is familiar: each joint turns to an angle, and the movements happen in the right order.
In earlier lessons we learned the robot's sense–decide–act loop. In a line-following robot we read a sensor, decided, and drove the motors. In a robot arm the "act" step changes: instead of wheels, we set servo motors to specific angles. Once you understand the sequence, you will understand how a real pick-and-place system thinks.
What is a servo, and why does it work with angles?
An ordinary DC motor spins continuously; if you do not tell it to stop, it keeps turning. A servo motor is different: you tell it an angle, and it turns to exactly that angle and holds it there.
Most small hobby servos move between 0 and 180 degrees. 0 is one end, 180 is the other, and 90 is the middle. Inside the servo there is a small gearbox and a circuit that measures position, so when you say "go to 90 degrees," it sets itself there.
Everyday example: a door handle
Think of a door handle. When you press it down, it moves to a certain angle; when you let go, it returns. A servo is similar, except you choose the angle and the servo stays there. You do not say "turn a bit," you say "go to 35 degrees." This is the same "clear command" rule from the algorithms lesson: precise, not vague.
Everyday example: the joints of your arm
Raise your own arm and pick up a cup. Without thinking, you set your shoulder, elbow and wrist angles separately. A robot arm thinks the same way: each joint is a servo, and each servo has its own angle.
A jointed arm: one angle per joint
A simple robot arm is made of a few joints. A typical learning arm has these joints:
- Base: Turns the arm left and right.
- Shoulder: Lifts the arm up and down.
- Elbow: Lets the arm reach out and fold back.
- Gripper: Opens and closes the holder at the tip.
The holder at the tip is called the end effector. In our example it is a gripper: open releases the object, closed holds it.
We can write the arm's current pose as a list of angles. For example:
base = 90 degrees
shoulder = 60 degrees
elbow = 120 degrees
gripper = open (0 degrees)
These four numbers fully describe one pose of the arm in space. Change the numbers and the arm moves to a new pose. So programming a robot arm really means changing these angle lists in the right order.
Pick-and-place logic: putting movements in order
Moving an object from one spot and setting it down at another is called pick and place. We cannot do it in one jump; we break it into small, ordered steps, just like in the algorithms lesson.
Let us pick up a pencil on the left and place it on the right. First we write the logic as pseudocode:
Start
Open the gripper
Move the arm above the pencil (set base and shoulder angles)
Lower the shoulder to the pencil's level
Close the gripper # the pencil is now held
Raise the shoulder # lift the pencil up
Turn the base to the right # carry it to the new spot
Lower the shoulder # come down to release height
Open the gripper # the pencil is released
Return the arm to a safe pose
End
The order really matters. Raise the shoulder before closing the gripper and the pencil stays behind. Open the gripper before lowering the shoulder and the pencil falls from a height. Break the order and the task fails; this is the "right order" rule on a robot arm.
Why do we wait between each movement?
Servos do not reach an angle instantly; they need a little time. If the code jumps to the next command too soon, the motion becomes jerky. That is why we add a short delay after each step.
Controlling a servo with code
Now let us turn the logic into a real Arduino (C++) example. Here is a small program that moves one servo to 0, 90 and 180 degrees and back:
#include <Servo.h>
Servo shoulder; // servo object
void setup() {
shoulder.attach(9); // servo signal wire on pin 9
}
void loop() {
shoulder.write(0); // go to 0 degrees
delay(700); // wait for it to finish moving
shoulder.write(90); // go to the middle
delay(700);
shoulder.write(180); // go to the other end
delay(700);
}
The command shoulder.write(90) tells the servo "go to 90 degrees," and delay(700) means "wait 700 milliseconds for it to settle." With several servos, we would create a separate Servo object and pin for each one.
Powering a servo straight from the Arduino's 5V pin often does not supply enough current; the arm jitters or the Arduino resets. That is why we use a separate battery pack for the servos. The negative terminals (GND) of the Arduino and the battery pack are connected together; this is called a common ground. Without it, the signal the Arduino sends means nothing to the servo.
Hands-on mini task
You can do this task even without a robot arm; the goal is to build the logic.
- On paper, write the four joints: base, shoulder, elbow, gripper.
- Put an eraser on the left of your desk and an empty box on the right.
- Write the steps that pick up the eraser and place it in the box as pseudocode. Use at least eight steps.
- Next to each step, note the current gripper state ("open" / "closed").
- Have a friend read the steps aloud while you mime the movement with your hand. If a step is missing, the eraser will drop or miss the box.
Tip: make sure "close the gripper" comes before "raise the shoulder." If you have a robot arm, first test one servo with the code above, then add the movements one at a time.
Common mistakes
Opening the gripper at the wrong time
If you open the gripper too early while carrying the object, it falls. The gripper should open only after the arm reaches the release spot at the correct height.
Not waiting between movements
Without a delay, a new angle arrives before the servo reaches its target and the arm shakes. Add a short wait after each meaningful movement.
Trying to power servos from the Arduino
Powering several servos from the Arduino's own pin is usually not enough. Use a separate battery pack and connect a common ground.
Going past the angle limit
Most hobby servos work only between 0 and 180 degrees. A value like write(200) strains the servo or wears its gears. Keep angles inside this range.
Forgetting the common ground
If you do not connect the GND terminals of the Arduino and the battery pack, the servo will not work properly, or will not move at all.
Safety note
A moving robot arm may look harmless, but it needs care. Joints and gears can pinch fingers, hair and cables.
- Before running the arm, clear the area; move away breakable items and cups.
- Keep fingers, hair and cables away from joints and gears. Never put a finger where the gripper closes.
- On the first try, work at low speed with small angle changes to see how the arm behaves.
- Use a separate, low-voltage battery pack for the servos and connect a common ground. Never use mains electricity (a wall socket).
- If the arm moves unexpectedly, cut the power (disconnect the battery) before touching it.
- Ask an adult for help when working with motors, batteries and tools.
Review questions
- Why is a robot arm usually controlled as a sequence of states rather than one long movement command?
- What limits should be checked before commanding a joint angle?
- How can the program respond if an object is not detected where expected?
- Why must power and mechanical load be considered together?
- What does a safe home position provide?
- Which tests should be completed before allowing the arm to move at full speed?
Answers
- States make each phase observable and testable, such as home, approach, grip, lift, place and return.
- Check the physical range, servo limits, collision risk, cable movement and any software safety boundary.
- Stop, release force, report the missing condition and return to a known safe state rather than continuing blindly.
- A motor may draw more current under load and stall or overheat even when the code asks for a valid angle.
- It gives the system a known reference for startup, recovery and repeatable movement.
- Test each joint separately, use reduced speed and force, verify emergency stop behaviour and inspect the workspace for collisions.
Lesson summary
- A servo motor goes to the angle it is told and holds it there; most work between 0 and 180 degrees.
- A robot arm is made of joints, each controlled by a servo; the arm's pose is described by a list of angles.
- Pick-and-place logic means arranging movements in the right order; you never raise the arm before the gripper closes.
- Servos do not reach an angle instantly; a short wait is needed after each movement.
- Servos are powered from a separate battery pack and share a common ground with the Arduino.
Check-up questions
- What is the main difference between a servo motor and an ordinary DC motor?
- What do we use to describe the pose of a robot arm?
- In a pick-and-place task, when should the gripper close: before lifting the object, or after?
- Why do we add a
delay(wait) between servo movements? - Why do we power servos from a separate battery pack instead of the Arduino, and what does "common ground" mean?
Answers
- An ordinary DC motor spins continuously; a servo goes to a specific angle it is told and stops there.
- We describe it with a list of angles, one for each joint (for example base 90, shoulder 60, elbow 120, gripper open).
- Before lifting the object; the gripper closes and holds the object first, then the arm is raised. If it opens early, the object falls.
- A servo does not reach its target angle instantly; without a
delaya new command arrives before the movement finishes and the arm shakes. - Because the Arduino's pin cannot supply enough current for several servos. A common ground means connecting the negative (GND) terminals of the Arduino and the battery pack together, which is needed for the signal to reach the servo correctly.
Source and verification note
For “Robot Arm Logic”, verification focuses on whether the relationship between What is a servo, and why does it work with angles? and Everyday example: the joints of your arm remains consistent across examples. Robot behaviour cannot be explained by code alone; mechanical structure, power system, sensor placement and surface conditions must be evaluated together. Test results should be recorded over several runs on the same course.
End-of-lesson check
- How would you define Robot Arm Logic in your own words?
- What is one normal use of the structure learned in this lesson?
- Which boundary or unexpected case would you test?
- How could you detect and correct one likely mistake?
- How would you adapt the same idea to another robotics or coding project?
End-of-lesson check — sample answers
- A good definition explains both the main idea and its purpose.
- The example should identify the input, the process and the resulting output.
- A boundary test can use the lowest or highest accepted value; an unexpected test can use missing or invalid input.
- Compare expected and actual results, change one thing at a time and repeat the test.
- Find the rule that remains the same, then adapt the steps to the new project’s input, tool and output.
Next lesson
Remote Control: The logic of steering a robot from a distance with a button, joystick or phone.