Course: CTE IT with Dobot
Lesson 4: Tower Sorting

  • 9-12 grade
  • Intermediate

Lesson Description:

Use what you learned in the last two lessons to build a color sorted tower.

image description

Lesson Modules

Teaching Tips:

Observe Module Overview

  • Teacher will grab student’s attention by asking them to look at the and video. 
  • They are to ask themselves what is this new command and how can it be used?
  • The teacher will demonstrate how it’s used in a real-world situation.

Lesson Overview

  1. Ensure the Dobot firmware and software is updated to the latest version. This will reduce troubleshooting.
  2. This lesson can be done individually or in groups. Depending on size of class or number of robots. If several students per robot, you might want to assign them separate responsibilities for full engagement.
  3. This lesson can take between 1 to 2 class periods depending on coding knowledge of students with Blockly ,Script, and Dobot in general.
  4. This lesson and skills is considered high consisting of much of the previous learned material.
  5. Having students start in the Power ON homing position is recommended, so that every student or group has their Dobot(s) start from the same spot.
  6. Remind students that in this project they are to use all previous knowledge such as variables, functions, loops, and lists.
  7. When programming remind students about turning on and off suction cup. Also, for students to use a medium setting on joint speeds. Very high might prove to be ineffective.
  8. We included a code sample of the process as shown on video. The 2nd challenge will vary but should be similar in design with additional codes.

Materials Needed:

Here is a lesson plan for your records.

Use this code solution as a reference for grading.

Here is a detailed explination of the code solution. It is useful to help students who are stuck in the prototyping process.

Optional Materials:

Print this Key Terms vocab sheet to use as a reference dring class

Print some more Pick and Place handouts

Teaching Tips:

Explore Module Overview

Student should be able to explain all the KEY TERMS up to this point. The teacher will check for this by asking questions:


  • What is a list?
  • How can it be applied in a real world product or situation?
  • How can I modify the code?

Higher order thinking question

  • What other ways do you think you could use lists with Dobot?

Also engage students in discussion about 

Answers to questions in the module:

Look at the second line of code, what do you think it does?

  1. it will get the 1st item on the list which is the Green color!!

You might be asking yourself “Why not just create 3 variables with the color in each?” Well you can, but what if you had to create a program for a company where they need to change the color, of the 100 colors available, for their to toy towers instantly!

All you would need to do in the code is move the color blocks in a different order and that’s it!! No having to create and/or renaming variables which could take serious time.

This is one huge advantage of lists, just like we’ve learned the advantages of variables, functions, and loops.

Look at this code, in what order would it print the cubes?

  1. It would make the 1st cube Green, the 2nd Yellow, and the 3rd Blue

You could make the job easier for yourself by just leaving the get #s in order and just maneuvering the blocks around in the order you want. This method would give you the same outcome as before, but you just change the color blocks around. This method will be in your challenge

Key Terms

  1. List - list (also called an array in other programming languages) is a tool that can be used to store multiple pieces of information at once. It can also be defined as a variable containing multiple other variables
  2. Color Sensor – This type of sensor can identify the color of an object by the amount of light the object reflects. Color Sensor will detect the intensity of Red, Green and Blue in color of the placed object and send it to microcontroller for further process.
  3. Light Dependent Resistor - An LDR is a component that has a (variable) resistance that changes with the light intensity that falls upon it. Every color detected creates a different brightness therefore identifying which color the object is.
  4. Microcontroller - A microcontroller (MCU for microcontroller unit, or UC for μ-controller) is a small computer on a single integrated circuit. The brain of the robot where the programming commands and sensor values are processed.
  5. Servo Motors - are DC motors that are equipped with a servo mechanism for controlling precise angular position. They usually have a rotation limit ranging from 90° to 180°.
  6. Input ports – It connects the microcontroller either to internal or external devices. For example, where you plug in the attachments to Dobot those are the input ports.
  7. Function -. is a named section of a program that performs a specific task.
  8. If-do command – a conditional statement perform different computations or actions depending on whether a programmer-specified condition evaluates to true or false.
  9. Variable – are used to store information to be referenced and manipulated in a computer program. You can think of them as containers that hold information.
  10. Blockly -  is a client-side JavaScript library for creating visual block programming languages and editors. It is a project of Google and is open-source under the Apache 2.0 License
  11. Cartesian coordinate system -  is a coordinate system that specifies each point uniquely in a plane by a pair of numerical coordinates
  12. Loop/Repeat - a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.

Look at the second line of code, what do you think it does?

Teaching Tips:

Prototype Module Overview

Each group or individual is to program Dobot with the following guidelines:

  • Dobot must check the list created for the color and order of the cubes
  • Dobot must transport the cube to the PICK location to build sorted tower

Part 1: Create a program using an “order” list of colors that would allow you to select what color you want and in what order for the tower.

Watch this video sample:

Dobot must do the following:

1.Check your list for the order of colors (from bottom - up)

2.Grab and place them in that order to make the tower

Part 2:

Dobot must do the following:

1.Check your list for the order of colors (top to bottom)

2.PICK and PLACE them in that order to make the tower.

3.Make a total of 3 towers, but must have 1 different colored cube as shown.

Teaching Tips:

Reflect Module Overview

  • Review with class on the benefit of using lists in their code as well as with robots
  • Review all the key terms with students they should know up to this point.
  • Have to students reflect and rate their performance as robot programmers. How many failed attempts? How much time?
  • Discussing on how much time it might of taken programmers in the field to get everything working as efficiently and safely as possible.

Questions and Answers

  1. In programming what is a list?
    1. A list is an ordered collection of items inside a variable.
  2. In a list, do the items have to be of the same type or can they be different?
    1. The can be different.
  3. Can the same value appear more than once in a list?
    1. Yes.
  4. What does the create list with block allow?
    1. allows the user to specify the initial values in a new list.
  5. Once you’ve created your list and executed the program, are you allowed to make changes to the list?
    1. Yes, you can always change the number of items by clicking on the gear.
  6. When you want to retrieve one of the items in the list you first use the SET block to name the variable and then attach what block to it?
    1. To retrieve items back you would use the in list block.
  7. What is one huge advantage of lists mentioned in the lesson?
    1. Allowes to change the items instantly and in any order, without having to create, rename, and delete variables in 100’s of lines of code.
  8. Did Dobot do anything unexpected while you were testing?

  9. Where did you identify the cause of it in your code?

  10. What did you find to be the most challenging part of the project?

  11. What new things did you learn during the project?

    1. Answers will vary