Simple Robot Arm With Lesson Plan for Circuits and Programming

Introduction: Simple Robot Arm With Lesson Plan for Circuits and Programming

Hello! I am an electronics engineering student who loves learning and teaching robotics. I run a robotics club at my college, and have been teaching other members the basics of circuitry and C programming. I decided that my work could make an amazing lesson plan for middle school/ high school students. The electronic components are relatively inexpensive, especially if you have access to a 3D printer. I have done my best to be as incremental as possible in my lesson plans, so that even beginners will be able to build and code the arm. I hope this plan will help inspire young minds and spark curiosity in S.T.E.M fields!

If you are a teacher and would like to use this in your classroom, please message me. I am interested in further developing this lesson plan to make robotics accessible to all.


For the wired circuit:

x1 Breadboard

x1 Arduino or Arduino Nano + USB cable

x1 10k ohm Joystick - be sure it is breadboard compatible

x3 10k ohm potentiometers

x6 12mm Normally open Push Buttons

x6 10k Ohm resistors


Wire cutter/stripper

For the circuit board:

x1 Circuit Board - order link coming soon

x1 Arduino Nano + micro USB cable

x1 10k ohm Joystick x3 10k ohm potentiometers

x6 12mm Normally open Push Buttons

x6 10k Ohm resistors

x1 .01 nF ceramic capacitor

x1 Sparkfun barrel power jack

x1 9v battery to barrel cable

x1 9v battery

Pin headers

Soldering Iron Kit (includes iron, holder sponge, and usually solder)

Solder, if none is included in the soldering kit

Helping Hands -

For the Arm:

One of each part here:

x3 9g servo -

x1 Ping pong ball

Small screwdriver - screws are included with the servos

For the code:

A computer with a USB port and access to the internet

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Optional Lesson: Wiring the Circuit

I recommend using Tinkercad to build a circuit because it offers some visual feedback to assist in basic circuit building. This way, students can get familiar with building circuits without the cost or time required with physical components. Instructors can always order physical components or the board in later lessons. The code examples included in future lessons can be uploaded and run in Tinkercad.

Use the attached images to build the circuit, either physically or in Tinkercad.

Once a circuit is created, students should also understand voltage. In this project, voltage is how we determine 'off' (0 volts) and 'on' (5 volts) in a language the Arduino can understand. If there is an active power source and a path to ground, voltage is created, and it is used in conjunction with current to power our robot.

Step 2: Optional Lesson: Soldering Components to the PCB

If you have ordered the board for this lesson, you will have the option to have components ship separate from the board. This gives students the opportunity to learn how to solder, and to really get hands on with the circuitry. Additionally, once boards are soldered, instructors do not need to troubleshoot circuits on an individual level, giving them more time to teach the lesson.

Step 1: Gather your equipment and components.

You will need:

x1 Circuit Board - order link coming soon
x1 Arduino Nano + micro USB cable

x1 10k ohm Joystick

x3 10k ohm potentiometers

x6 12mm Normally open Push Buttons

x6 10k Ohm resistors

x1 .01 nF ceramic capacitor

x1 Sparkfun barrel power jack

x1 9v battery to barrel cable

x1 9v battery

Pin headers

Soldering Iron Kit (includes iron, holder sponge, and usually solder)

Solder, if none is included in the soldering kit

Helping Hands -

Step 2: Discus safety

Soldering irons are hot and can cause minor burns if handled incorrectly. Only hold the soldering iron by the padded grip and never touch any metal parts of the iron during or after use. Safety glasses should be worn to protect vision. Gloves are not recommended - it is much easier to sense heat with bare skin. Wearing gloves not only encourages dangerous behavior, but can cause worse injury if the student is not aware of the issue. I also recommend any instructors read the following article about giving kids the opportunity to play dangerously -

Step 3: Technique

Soldering is simply the process of creating an electrical connection between two points. The board uses through-hole soldering process, in which metal legs of the components are put through the board and soldered on the bottom. For components like the thumbstick and buttons, the legs are short and thick. These can simply be held in place by your helping hands tool and soldered. For components like resistors with thin, long legs, the legs can be bent, slotted through the holes, and bent outwards to hold them in place. The extra metal can be snipped of once soldered. When soldering, the best way to achieve a strong bond is by using the iron tip to heat the metal on the board and the component for a second, apply solder to the metal, not the iron, then remove both. Here is a good video explaining the process:

Step 3: Set Up Your Coding Environment

In order to download code to the Arduino board, students need the Arduino IDE (Integrated Development Environment). The setup instructions are below:

On a laptop or desktop computer, use this link to download the Arduino IDE (Integrated Development Environment) - Install and launch the software and you’re ready to go! Be sure you have the correct board selected by going to Tools < Board < Arduino Uno or Nano

When you plug your Arduino into the computer, be sure you have the correct port selected by going to Tools < Port < select the port with your board name next to it. If you do not see it, plug your Arduino into the computer.

To download the code examples used in this Instructable, go to this link:

Click on 'Clone or Download' < download to zip file.

Step 4: Lesson 1: 3D Printing Parts and Arm Assembly

3D printing has revolutionized how makers generate parts for their project. Each part can be printed on demand and be finished within an hour, costing less than a dollar for materials. If your students are interested in the modeling and printing process, these parts can be customized and adapted. If your students are already using Tinkercad, then they have access to a very intuitive and user friendly modeling software. For advanced designs, I recommend using Fusion 360, which has a free license for students and educators.

To download the .STL files for this arm, simple follow this link to my Thingiverse page:

Click on the 'Download All Files' button. You now have the files used for printing. If you do not have access to a printer, there may be a maker space in your area that could print these for a small fee. If you are considering buying a printer to work on this project, be sure the printer bed size is at least 120mm x 120mm x 120mm.

Once you have all your parts printed, follow these instructions to assemble the arm. Use the pictures included as a reference.

Step 1: Set up the base

Rotate your base servo fully clockwise. Place the arm on the servo so it is pointing between both legs of the base. Use at least one screw to secure the servo to the base. Be sure the servo is positioned correctly, so the wires come out of the slot in the left side.

Step 2: Add the mid joint

Place the mid joint on the servo-arm so that the cutout sits flush with the arm. Mount the Mid 90 degree Joint to the base servo with a screw.

Step 3: Mount the mid servo

Rotate the mid servo fully clockwise. Position the mid servo so the rotating bit is forward. Attach the arm in a vertical position. Secure the servo to the mid joint with at least one screw.

Step 4: Mount the Main Arm

Place the main arm over the servo-arm so that the arm and the cutout are flush. Secure the main arm with a screw.

Step 5: Mount the claw servo

Rotate the claw servo fully clockwise. Place the servo in the main-arm cutout so that the rotating bit is far from the main arm. Place the arm on the claw servo vertically, so that it is parallel with the main arm. Secure the servo to the main arm with at least 1 screw.

Step 6: Attach the claw part

Place the claw part over the servo arm so that the arm and the cutout are flush. Secure with a screw.

Optional Step 7: Attach the spare circle

This part can be used as a second location to move a ping pong ball to, or from. Additionally, multiple arms can be linked together using the male and female circles on the base.

Step 5: Lesson 2: Control an LED

In this lesson, students will learn the basics of using code to control the flow of electricity to a circuit, thus illuminating an LED. This can be done in Tinkercad, or by using the surface mounted LED that is tied to pin 13 on Arduino boards.

Challenge 1: Turn on and LED

To do this, students will need to write and understand two lines of code. Please note the code is case sensitive. The first is Pinmode, which is shown below:

pinMode(Pin number, INPUT/OUTPUT);

Example: pinMode(13, OUTPUT);

Digital pins can be used as inputs or outputs - so we need to tell the Arduino board to use this pin to output voltage. Place the example line of code in the voidSetup() loop. The second line of code is:

digitalWrite(Pin, HIGH/LOW);

Example: digitalWrite(13,HIGH);

DigitalWrite is the most basic way to tell a pin what to do. Remember that digital pins are binary, so they can only ever be off (LOW) or on (HIGH). Place the example code in the voidLoopI() loop.

Upload "Lesson2_Challenge1_LED" code to the board - students should see a solid light.

Challenge 2: Blink and LED.

This task is a little more challenging that it seems. In theory, we should only have to turn off the LED once we turn it on. If we do this, we find that the LED appears to remain illuminated, albeit slightly dimmer than before. This is because the Arduino is running through our code so quickly, and the LED is blinking so rapidly, it appears to be a solid light. You may want to run this experiment and see if students can figure out why this is occurring. In order to blink an LED at a rate the human eye can detect, we will use the delay command.

delay(time to delay in milliseconds);

Example: delay(1000);

This command forces the program to pause for the time specified in milliseconds. For reference, 1000ms = 1 second, 2000ms = 2 seconds, 500ms = half a second. Simply place a delay command after each digitalWrite. Your code should look like the example below:

Upload "Lesson2_Challenge2_Blink" code to the board - students should see a blinking light.

Step 6: Lesson 3: Digital Servo Control

In this lesson, we will explore the properties of a servo motor and how we can use code to control them. While there are many types of servos, most consist of three components - a motor, a drive train or gear ratio, and a controller. When a signal is sent from the controller (in our case, the arduino), power is sent to the motor, which rotates a series of gears. This gear ratio gives the servo a lot of torque, or twisting force. This torque is desired because the servo can still operate when under load, such as when our arm is carrying a heavy object.

A characteristic of this brand of servo is a limiting block on the drivetrain that limits the rotation from 0-180 degrees. This is ideal for beginners, since uncontrolled rotation can result in damage to components or the servo itself. The servo has three wires; orange, red and brown. The red wire is our 5 volt power wire, the brown wire is our ground, and the orange wire is our signal wire. In order to control a servo, we must use a pulse-width modulated signal (PWM). Luckily, most of the hard work is done for us, and we just need to connect the orange wire to the correct digital output. On the arduino board, PWM enabled pins are represented with “~” symbols. IMAGE. By varying the high and low time of a PWM signal, we can control how much voltage is sent to a destination. For example, let’s say a 5 volt power source is pulse-width modulated with a 50% duty cycle (half on, half off). The servo would effectively see 2.5 volts, and move to a middle position. The Code Setting up servo control in the Arduino IDE requires a few more lines of code, but it still follows the basics of LED setup. We need to tell the Arduino what pins are being used, what those pins are controlling, and how to control it.

Please note that this lesson can be conducted using Tinkercad, although it is much more interesting for students to see in real life.

Upload the code 'Lesson 3_Example1_1Servo'. Have students write the base servo to different positions. We are only using the base servo as an example - using the other servos without proper codding can result in damage to the arm or the servos. We will control all 3 in the analog lesson.

Coding Lesson: If-Then Statements

One of the most useful blocks of code that beginner programmers can learn is a case statement, also known as an 'if-then' statement or a branching path statement. This allows students to program their robot with basic decision making. The syntax is below:

if (comparison) {

Do this thing if comparison is TRUE;


Here are a few examples of comparisons:

if (4 < 3) -this statement uses two static values. The code will check to see if 4 is less than (<) 3, which will always be false. This is why we want to use at least one variable when writing case statements.

if (Variable == 1) -This statement compares a variable to a static value. The code will check to see if our variable is equal (==) to 1. When Variable equals 1, the statement will be true.

if (Variable >= Variable2) -This statement compares two variables. The code will check to see if Variable is greater than, or equal to (>=) Variable 2.

You can read more about comparisons and boolean operators here:

Challenge 1: Move the servo to a position by pressing a button

This is a relatively straightforward challenge with a simple solution. Students can use digitalRead(any button pin) to determine if a button has been pressed. They can then use a case statement to write the servo to any position of their choosing.

Upload 'Lesson_3_Challenge1_Button' to the board and see what happens. Students should be able to use buttons 1 and 2 to move the base servo. See if students can program more buttons with more base positions.

Challenge 2: Servo Sweep In this challenge

Students must write the servo from position 0-180 without the students providing input. Most likely, students will hard code the instructions like below:










While this solution will (eventually) work, there is an easier way - increments. Example:

int variable = 0;


This simple code will add one to a numeric variable each time it is run. Using this, we can accomplish the challenge with only a few lines of code.

Upload 'Lesson_3_Challenge2_Increment' and see what happens. Students should see slow rotation as they hold down buttons 1 and 2.

Keep this code handy, as it will be useful for challenges in the next lesson.

Step 7: Lesson 4: Advanced Digital Control

This lesson will build on the skills we learned in the previous lesson. We are continuing with digital control, however, since a lot of the code we are writing is repetitive, the coding lesson will cover some efficiencies.

Coding Lesson: Variables

If students have taken or are taking algebra, they should be familiar with variables. If your students have not taken this class yet, here is a simple explanation. A variable, represented by a letter (X) or a word (Variable), can represent any value we want it to. Or variable 'X' can be 0, -12, or eight billion. This is the most important function of a variable - is it's ability to hold a value. This is because we can now use our code to modify the value our variable holds.

We also use variables because it is much easier to code with words. For instance:

if (3 > 1) {

digitalWrite(4, LOW);


If you were not the original author, you would have no idea what it is trying to accomplish.

if (Counter > 1) {
digitalWrite(LEDpin, LOW);


By using variables, we not only make the code clear to all readers, but it makes it easier to trace through your code to find errors.

Coding Lesson: Basic Functions

A function can be thought of as a variable for lines of code. This is especially useful for code that needs to be run a lot. One way to explain a function is by using the peanut-butter sandwich example. Ask your students to list the steps needed to make a peanut-butter sandwich. Your list might look something like this:

Get bread

Get Peanut-butter

Open Jar

Get Knife

Spread peanut-butter on slice 1

Spread peanut-butter on slice 2

Put slices together

Explain that when you ask someone to make a sandwich, you don't need to ask them to do every individual step. Asking for a sandwich automatically includes the steps required. A function works the same way. Any steps included in the function will be run when the main function is called in voidSetup() or voidLoop(). Here is an example of a function:

void exampleFunctionName(){

digitalWrite(LEDpin, HIGH);


digitalWrite(LEDpin, LOW);



This function can be called by simply writing exampleFunctionName() in your main code. Each time it is run, it will simply blink an LED.

Challenge 2: Increment Movement

In this challenge, students will use 6 buttons to control all 3 servos. There are two buttons for each servo, one for positive movement, the other for negative. Each time a button is pressed, the variable used to control the servo position will either increment or decrement. Students should write a function for each of the 6 buttons.

Upload 'Lesson4_AdvancedProgramming_DigitalControl' and see what happens. Students should be able to control all three axes with the buttons.

Step 8: Lesson 5: Analog Control

What is analog? If we remember all the way back to lesson 1, we defined digital Boolean as two states - on and off. If we use a light switch as an example, the only states we can have are on and off. An analog value can be anywhere between the off and on state - much like a dimmer switch. Since there are 8 bits of memory associated with each analog pin, the light can have 1023 different states of brightness.

To control these states of brightness, we are using a device called a potentiometer. This device is known as a variable resistor because as we rotate the knob, it increases or decreases the amount of resistance, which increases or decreases the voltage we send to the Arduino. To demonstrate this, we first need to learn some code.

Code Lesson: Serial Print and the Serial Monitor

The serial monitor is an amazing tool that we can use to see what our code is doing. To use it, we need two lines of code:


This code needs to be included in your Void setup() loop. It establishes a serial connection between the board and the computer. The number 9600 refers to the baud rate, or, the rate at which data is transferred.

In order to print something to the serial monitor, we use:

Serial.print("1"); - This will print on the same line each time it runs - 111111


Serial.println("1"); - This will print on a new line each time it runs -





If we place a constant, such as a number or a phrase, we need to use quotation marks.

If we place a variable, do not use quotation marks. The code will print the value of that variable each time it runs.

Now, to demonstrate an analog device, upload 'Lesson5_AnalogControl_Serial'. Open the serial monitor (magnifying glass icon in the top right corner, see image) and observe the value shown. Slowly rotate the potentiometer and see how the values change from 0-1023. You may notice in the code that there is no pinMode for the analog pin. This is because these analog pins are input only, which is why we used digital output PWM to control the servo. The next step is to use these analog pin values to control our servos. We can do this by simply passing the analogRead value to our Servo.write() command.

Upload 'Lesson5_AnalogControl_BaseServo' and see what it does. Students should be able to control the base servo with the a potentiometer.

You may notice that the servo was able to move the entire length of its 180 degree travel, only a small fraction of the potentiometer’s rotation was used. Remember that the servos we are using only have a range of 0-180. Values over 180 have no effect. We can fix this by using a map function.

Upload 'Lesson5_AnalogControl_MappedServo'. The base servo should now move with the potentiometer.

This function takes the second set of values and distributes them equally to our first set. If we divide 180 by 1023, we get roughly 0.18. This means that each increment of rotation from our potentiometer increases our servo position by 0.18, so we are able to use the full rotation of our potentiometer to control the full range of the servo.

Challenge: Safely control all 3 servo axes using potentiomenters

Remember that a limitation of the physical arm is that the mid and claw servos can be over rotated, which may result in damage to the parts or the servos. To correct this, we can use three different map functions, one for each of the servos. To do this, have students determine an acceptable range for each servo. For instance, 130-140 may be a good maximum for the claw. Once this range is determined, have students write the map function for each servo and test it out.

Upload 'Lesson5_Analog_Control_Challenge3' and replace the map values with the ones your students recorded. They should be able to safely control the arm with the three potentiometers.

Step 9: Lesson 6: Thumb Stick Control

The lessons up to this point have been focused on learning new code and control techniques. This lesson is a little different, as the basis for using a thumb stick has already been taught in the previous lesson. Instead, this is a great opportunity to experiment and play with the arm. Furthermore, activities that encourage teamwork, communication and planning can be conducted. I’ve included a few ideas at the end of this lesson.

If you look at the thumb stick component, you may recognize that it consists of two potentiometers. Controlling an arm with a thumb stick is nearly identical to how we used potentiometers in the previous lesson. One potentiometer is labeled as the X-axes, and the other is the Y-axes. When the thumb stick is in the default position, both axes should have an analog read value of around 500-512.

Upload 'Lesson6_ThumbstickControl' and try it out. Once the serial monitor is running, slowly move the thumb stick along the X and Y axes and watch how the values change. Be sure to record which direction results in what value, as we will be using these later on in the lesson.

Challenge 1: Enable the Claw

Start with the code referenced above. The goal of this challenge is to use any of the previous lessons to control the claw. This can be done a couple of different ways. The easiest is by simply copying the potentiometer control code from lesson 6, or the 2-button open/close code from lesson 5. A third option is by using two push buttons, one writing to an open position, the other writing to a closed position.

A fourth option is to follow the previous example but only use one button. The claw should start open. A button push should put the claw in a closed position. Pressing the same button should open the claw. Some example code to accomplish this can be found by uploading 'Lesson6_ThumbstickControl_Challenge1'

Challenge 2: Teamwork

Once there are enough students who have a working arm (though any configuration), it’s time to give them a challenge. Have students place their arms in a line, and see if they can pass a ping pong ball from start to end. Pay close attention to the group dynamic. How are students communicating? Is there a leader? How does the group deal with failure? All of these can be valuable teachable moments and lead to great discussions on how humans interact. Once students begin to master the activity, continue to pile on the challenges. See if they can do it without speaking. See if they can do it blindfolded with a single voice giving them instructions. Most importantly, make sure any victory is celebrated and encouragement is given freely. The final challenge should be a time trial with as many students as possible. The goal is to see how quickly they can get the ball from start to finish. Encourage the group to brainstorm the process and see if they can develop a more efficient way to accomplish this task. For instance, students may find it is faster for two people to control a single arm. Another option is for students to begin comparing their control code and look for the most efficient one. This code can then be loaded onto everyone’s board and the process run again. There are limitless possibilities for how students may accomplish this goal - it is your job as the facilitator to encourage new ideas, and guide students towards solutions.

Step 10: Lesson 7: Automation

In this lesson, we will introduce one final code topic, and continue with our teamwork/communication focused activities. At the end of this lesson, students should be able to automatically pick up a ball and place it elsewhere.

First and foremost in this lesson, it is important to frame a conversation around automation. Student’s may have different opinions or ideas about automation, and it’s important to discuss the topic fully before beginning the activity. At its core, automation is the act of using a machine to do something. It can be as simple as move an object on an assembly line, or as complex as safely drive a car. There are many benefits to automation, such as efficiency, decreased cost over time, and less workload for humans. Unfortunately, the automation revolution has displaced a lot of workers, and as a result, many see automation as a bad thing. This topic could be an opportunity to discuss how a human’s role could evolve with automation, instead of being replaced by it. If your student’s completed the assembly line activity in the previous lesson, this could be a great frame for the discussion. This activity is explained further below.

Coding Lesson: Arrays

In previous examples, we have used variables to represent a single number. An array does this with multiple numbers.

Example: Int RegularVariable = 12; Int ArrayName[] = {0, 2, 4, 5, 8, 10};

Each number is stored in sequential order, but you can call specific numbers.

ArrayName[0]; would return a 0. ArrayName[1]; would return a 2. ArrayName[2]; would return a 4. ArrayName[3]; would return a 6. Etc…Now we are going to take it one step further. You can also store arrays in an array. This creates a 2-dimensional array.

Example: Int ArrayName[][] = {{0, 1, 2}, {3, 4, 5}, {6, 7,8}};

ArrayName[0][0]; would return a 0. ArrayName[1][2]; would return a 5. ArrayName[2][2]; would return a 8.

The first number references the array groups - ‘ArrayName[0]’ refers to {0,1,2}. The second number references the position of your desired number within the specified array.

Once this data structure is understood, we can use it to automatically control our arm. We are using unconditional control, meaning we are just moving the arm to predefined positions each time. This is a great use for an array. Now, we just need to find the numbers we need. If you remember way back to our analog lesson, we used the serial print command to establish a safe range of arm operation. We are going to do the same thing here, but instead of testing the range, we will be recording each servo position that corresponds with our position case in Activity 1 below.

Activity 1: Create Movement Array

The first step it to create a list of all movements required to pick up a ball and place it somewhere else. The list should look something like this:

Move base Left

Move Mid Down

Close Claw

Move Mid Up

Move Base Right

Move Mid Down

Open Claw

Move Mid Up

Now that we have a concise list, we need to assign servo position numbers to each step. Students can do this by using the serial monitor + Analog control code below. Be sure that each servo position is recorded for each step, even if it is not used in that step.

Re-upload 'Lesson5_AnalogControl_Serial' code. Run the code with the serial monitor open.

The List should now look something like this:

Move base Left - Base 0 | Mid 0 | Claw 180

Move Mid Down - Base 0 | Mid 90 | Claw 180

Close Claw - Base 0 | Mid 90 | Claw 135


You may have gathered that we are building a two-dimensional array. This will be used to automatically control the arm by writing the assigned number to each servo for every step.

Upload 'Lesson7Automation' and see what it does. Students should be able to see the arm pick and place the ping pong ball without direct control.

Challenge 1: Automated Assembly Line

Once all students have automated code running on their arms, it is time to set up another assembly line. The first task is simply getting a ping pong ball from one side of the table to the other using the robot arms. See if the automated arms are faster than the human controlled arms (they should be). Students can also be challenged to see how many ping pong balls they can get across the table in 5 minutes.

Once this is accomplished, begin giving the students extra tasks, such as:

- Placing ping pong balls in a box once they cross the table.

- Inspecting every 5th ping pong ball at one of the robot arm stations

- Tallying ping pong balls on a piece of paper

- Have student keeping time, and every 3 minutes, all ping pong balls on the assembly line must be paused and the line inspected

As in the previous example, encourage students to brainstorm and plan how they will accomplish these tasks with the additional workload. It is possible that some students will want to further automate some of these tasks, such as automatically counting balls at the last station. This is highly encouraged for a few reasons. The first is that students will be able to practice their skills and think critically about the challenge. Secondly, it's a great example of jobs that can be created through automation.

Have students think back to the assembly line in the previous lesson when each of them had to control their arm by hand. The task wouldn't have been accomplished if one or two of them were off programming. But now that the automated controls take care of the repetitive work, students now have time to peruse more interesting endeavors. This can be applied to students doing the assigned tasks as well - they are able to work on more interesting / fulfilling tasks now that they don't have to control an arm.

Robotics Contest

Participated in the
Robotics Contest

Be the First to Share


    • Magnets Challenge

      Magnets Challenge
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest