Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Fundamentals of Robotics Level One · Lesson 4 of 12

Module Three

📖 Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
4
Module 3: Fundamentals of Robotics – Programming for Robotics

Module 3: Programming for Robotics

Module Introduction
Welcome back, robot builders! In Module 1, we learned what a robot is. In Module 2, we learned how to power a robot with electricity and circuits. Now comes the most exciting part – programming! Programming is how we give our robot instructions. It is like teaching a robot a language it understands. Without programming, a robot is just a pile of parts that do nothing. With programming, it comes to life! In this module, we will learn how to write simple programs to make robots move, sense, and make decisions. We will start with visual programming (like Scratch) and then look at text-based programming (like Python). By the end, you will be able to write your first robot programs. Let's bring your robot to life!

Learning Objectives

  • Understand what programming is and why it is important for robots.
  • Learn the difference between visual programming (like Scratch) and text-based programming (like Python).
  • Understand basic programming concepts: instructions, sequence, loops, and conditions.
  • Write simple programs to make a robot move forward, turn, and stop.
  • Learn how to use sensors in programs (e.g., if-then statements).
  • Understand how to upload code to a robot controller (like Arduino or micro:bit).
  • Debug simple programs (find and fix errors).
  • Create a program that makes a robot follow a line.

Warm‑up Story: Tunde's First Program

Tunde is 11 years old. He built a robot car with his uncle. It had wheels, a battery, and a small computer board called a micro:bit. But when he turned it on, the car just sat there. "Why won't it move?" he asked. His uncle smiled and said, "Because you haven't told it what to do yet! A robot needs instructions – that's called programming." Tunde opened his laptop and saw a colourful block-based program. He dragged a block that said "move forward" and connected it to a block that said "forever." He clicked "upload," and the car started moving! Tunde was amazed. He added more blocks: "if the light sensor sees darkness, turn left." His robot could now follow a line. Tunde learned that programming is like giving a robot a recipe – step by step, it does exactly what you tell it.

Main Lessons

Lesson 1: What is Programming?

Definition: Programming is the process of giving a robot (or computer) a set of instructions to follow. These instructions are called a program.

Why it's important: Programming makes robots smart and useful. It tells them what to do, when to do it, and how to respond to the world.

Simple explanation: Programming is like writing a recipe for a robot. The recipe tells the robot step‑by‑step what to do.

Real‑life example: The program in a washing machine tells it when to fill with water, when to spin, and when to stop.

School example: You might use Scratch to program a character to move on the screen.

Home example: A programmable thermostat uses a program to turn the heater on and off.

Nigerian example: A Nigerian engineer writes a program for a drone to spray crops in a farm.

+------------------------------------------+
|         What is Programming?              |
|------------------------------------------+
|  - Giving instructions to a robot         |
|  - Like a recipe for a robot              |
|  - Tells the robot what to do             |
|  - Makes robots smart and useful          |
|  - Robots only do what they are           |
|    programmed to do                       |
+------------------------------------------+

Mini summary: Programming is giving a robot instructions. It is how we make robots useful.

Lesson 2: Visual Programming – Using Blocks

Definition: Visual programming is a way to program using blocks that snap together like puzzle pieces. You don't need to type any words. Scratch is a popular visual programming language.

Why it's important: Visual programming is great for beginners because it is easy to learn and understand. You can see what each block does.

Simple explanation: Visual programming is like building with LEGO blocks. Each block has a job, and you snap them together to make a program.

Real‑life example: Scratch is a visual programming language used by millions of kids around the world.

School example: Many schools teach visual programming with Scratch to introduce coding.

Home example: You can use Scratch at home to make stories, games, and even control robots.

Nigerian example: Nigerian schools are starting to use Scratch to teach children how to code.

+------------------------------------------+
|      Visual Programming Example           |
|------------------------------------------+
|  [when green flag clicked]                |
|       ↓                                   |
|  [move 10 steps]                          |
|       ↓                                   |
|  [turn right 15 degrees]                  |
|       ↓                                   |
|  [if touching edge? then]                 |
|       ↓                                   |
|  [bounce]                                 |
|                                        |
|  Blocks snap together like puzzle pieces  |
+------------------------------------------+

Mini summary: Visual programming uses blocks that snap together. It is great for beginners.

Lesson 3: Text‑Based Programming – Writing Code

Definition: Text‑based programming is when you type words and symbols to write a program. Python, C++, and JavaScript are examples of text‑based programming languages.

Why it's important: Text‑based programming is more powerful and flexible than visual programming. It is what professional programmers use.

Simple explanation: Instead of snapping blocks, you type instructions in a language the robot understands.

Real‑life example: Python is a text‑based language used to program robots, websites, and AI.

School example: Older students learn to write Python code to control robots.

Home example: You can write Python code to make a Raspberry Pi robot move.

Nigerian example: Nigerian university students learn C++ and Python to build advanced robots.

+------------------------------------------+
|      Text‑Based Programming Example       |
|------------------------------------------+
|  import time                              |
|  from robot import *                     |
|                                        |
|  while True:                             |
|      if light_sensor() > 50:             |
|          move_forward()                  |
|      else:                               |
|          turn_left()                     |
|      time.sleep(0.1)                     |
|                                        |
|  This is Python code for a line‑follower |
+------------------------------------------+

Mini summary: Text‑based programming uses typed instructions. It is more powerful but harder to learn.

Lesson 4: Instructions – One Step at a Time

Definition: An instruction is a single command that tells the robot to do one thing, like "move forward" or "turn on the LED."

Why it's important: A program is made of many instructions. The robot follows them one by one in order.

Simple explanation: Instructions are like steps in a recipe. You do step 1, then step 2, then step 3.

Real‑life example: A program to bake a cake would have instructions like "mix flour," "add eggs," "bake for 30 minutes."

School example: You write instructions to make a character move across the screen.

Home example: A robot vacuum follows instructions like "go forward," "turn right," "clean for 5 seconds."

Nigerian example: A drone program has instructions like "take off," "fly to location," "land."

+------------------------------------------+
|       Instructions in a Program           |
|------------------------------------------+
|  Program:                                 |
|  Instruction 1: Start                     |
|  Instruction 2: Move forward 2 seconds    |
|  Instruction 3: Turn right 90 degrees     |
|  Instruction 4: Stop                      |
|  Instruction 5: End                       |
|                                        |
|  Robot follows them in order             |
+------------------------------------------+

Mini summary: Instructions are single commands. A program is a list of instructions the robot follows in order.

Lesson 5: Sequence – The Order of Instructions

Definition: Sequence is the order in which instructions are executed. The robot follows instructions from top to bottom, one after another.

Why it's important: The order of instructions matters! If you tell a robot to turn before moving, it will act differently than if it moves first.

Simple explanation: Sequence is like a dance routine. You do step 1, then step 2, then step 3 – in that exact order.

Real‑life example: A recipe says "crack eggs, then whisk, then pour into the pan." You can't whisk first!

School example: A program that makes a robot dance has a specific sequence of moves.

Home example: A robot vacuum cleans in a sequence: move forward, turn, move forward, turn.

Nigerian example: A robot in a factory follows a sequence: pick up part, move right, place part, return.

+------------------------------------------+
|         Sequence Example                  |
|------------------------------------------|
|  Instruction 1: Move forward 1m           |
|  Instruction 2: Turn left 90°             |
|  Instruction 3: Move forward 0.5m         |
|  Instruction 4: Turn right 90°            |
|  Instruction 5: Stop                      |
|                                        |
|  This sequence makes the robot go around  |
|  a corner and stop.                       |
+------------------------------------------+

Mini summary: Sequence is the order of instructions. The robot follows them in that exact order.

Lesson 6: Loops – Repeating Instructions

Definition: A loop is a way to repeat a set of instructions multiple times. You can loop forever or a specific number of times.

Why it's important: Loops save us from writing the same instructions over and over. They let robots do repetitive tasks.

Simple explanation: A loop is like a record player that keeps playing the same song on repeat.

Real‑life example: A robot vacuum uses a loop: "clean for 5 seconds, turn 90°, repeat forever."

School example: You use a loop to make a sprite bounce around the screen forever.

Home example: A washing machine has a loop: "spin, drain, rinse" that repeats.

Nigerian example: A water pump robot uses a loop: "check moisture, if dry, water for 10 seconds, wait 5 minutes, repeat."

+------------------------------------------+
|         Loop Example                      |
|------------------------------------------+
|  forever:                                 |
|     move_forward()                        |
|     if obstacle_detected():               |
|         turn_left()                       |
|  end forever                              |
|                                        |
|  This loop makes the robot keep moving   |
|  and turning when it sees obstacles.     |
|  It never stops!                         |
+------------------------------------------+

Mini summary: Loops repeat instructions. They are useful for repetitive tasks.

Lesson 7: Conditions – Making Decisions

Definition: A condition is a rule that checks if something is true or false. The robot uses conditions to make decisions: "IF something is true, THEN do this."

Why it's important: Conditions allow robots to react to the world around them. They make robots "smart."

Simple explanation: A condition is like a question: "Is it raining?" If yes, take an umbrella. If no, don't.

Real‑life example: A thermostat has a condition: "IF temperature is below 20°C, THEN turn on the heater."

School example: In Scratch, you use "if-then" to make a sprite change direction when it hits the edge.

Home example: A nightlight uses: "IF it is dark, THEN turn on the light."

Nigerian example: A solar tracking robot uses: "IF light is brighter on the left, THEN turn left."

+------------------------------------------+
|         Condition Example                 |
|------------------------------------------+
|  IF light_sensor() > 50 THEN              |
|      move_forward()                       |
|  ELSE                                     |
|      turn_left()                          |
|  END IF                                   |
|                                        |
|  If light is bright, move forward.        |
|  If light is dark, turn left.             |
|  This helps a robot follow a line!        |
+------------------------------------------+

Mini summary: Conditions help robots make decisions. They use "IF-THEN" logic.

Lesson 8: Variables – Storing Information

Definition: A variable is like a box where a program can store information, like a number or a word. You can change what is inside the box at any time.

Why it's important: Variables let robots remember things. For example, a robot can count how many steps it has taken.

Simple explanation: A variable is like a labelled jar. You can put things in it, take things out, or change what's inside.

Real‑life example: A program uses a variable called "score" to count points in a game.

School example: In Scratch, you use variables to keep score in a game.

Home example: A robot vacuum uses a variable to remember how much time it has cleaned.

Nigerian example: A farm robot uses a variable to store how many seeds it has planted.

+------------------------------------------+
|         Variable Example                  |
|------------------------------------------+
|  steps = 0                                |
|  steps = steps + 1                        |
|  steps = steps + 1                        |
|  print(steps)   # This will show 2       |
|                                        |
|  The variable "steps" stores how many     |
|  steps the robot has taken.               |
|  It starts at 0 and increases by 1       |
|  each time the robot moves.              |
+------------------------------------------+

Mini summary: Variables are boxes that store information. Robots use them to remember things.

Lesson 9: Programming a Motor – Move Forward

Definition: To move a robot, you program the motors to spin. Writing code to control motors is called "motor control."

Why it's important: Motors make robots move. Programming them is how we tell robots where to go.

Simple explanation: Programming a motor is like telling a car to go forward, reverse, or stop.

Real‑life example: A self-driving car's program tells the motors when to speed up and when to turn.

School example: You write code to make a robot car drive in a square.

Home example: A robot mower uses motor programs to move in patterns.

Nigerian example: A robot used for delivery uses motor programs to navigate streets.

+------------------------------------------+
|      Programming a Motor                  |
|------------------------------------------+
|  // Micro:bit with motor driver           |
|  pins.analog_write(0, 255)   // Left motor forward |
|  pins.analog_write(1, 0)     // Left motor stop   |
|  pins.analog_write(2, 255)   // Right motor forward|
|  pins.analog_write(3, 0)     // Right motor stop  |
|                                        |
|  This code makes the robot move forward. |
|  Change the pins to make it turn.        |
+------------------------------------------+

Mini summary: Programming motors controls how a robot moves. You write code to go forward, back, or turn.

Lesson 10: Programming a Sensor – Reading Data

Definition: To use a sensor, you write code that reads the sensor's data. The data might be a number (like light level) or a yes/no answer (like touch).

Why it's important: Reading sensor data is how robots "see" the world. They use the data to make decisions.

Simple explanation: Reading a sensor is like asking a robot "what do you see?" and it answers with a number.

Real‑life example: A camera sensor sends data to a computer to recognize faces.

School example: You read a light sensor to make a robot follow a line.

Home example: A motion sensor sends data to turn on a light.

Nigerian example: A soil moisture sensor sends data to decide when to water crops.

+------------------------------------------+
|      Reading a Sensor Example             |
|------------------------------------------|
|  // Reading a light sensor on micro:bit   |
|  light_level = pins.analog_read(0)        |
|  if light_level > 500:                    |
|      display.show("Bright")               |
|  else:                                    |
|      display.show("Dark")                 |
|                                        |
|  The sensor reads a number.               |
|  The program decides what to do based    |
|  on that number.                          |
+------------------------------------------+

Mini summary: Programming sensors means reading their data. Robots use sensor data to understand the world.

Lesson 11: Line‑Following Program – Bringing It Together

Definition: A line‑following robot uses a light sensor to follow a dark line on a light surface. The program reads the sensor and tells the motors how to steer.

Why it's important: This is a classic robot project that teaches you how to combine sensors, motors, and programming logic.

Simple explanation: The robot looks at the floor, sees the line, and turns to stay on it.

Real‑life example: Robots in factories follow lines on the floor to carry goods.

School example: A robotics competition where robots race to follow a line track.

Home example: A toy robot that follows a drawn line.

Nigerian example: A robot used in a warehouse to follow a path and deliver items.

+------------------------------------------+
|      Line‑Following Program (Simplified)  |
|------------------------------------------+
|  while True:                              |
|      left_sensor = read_left_sensor()     |
|      right_sensor = read_right_sensor()   |
|                                        |
|      if left_sensor > 500 and right_sensor > 500: |
|          move_forward()                  |
|      elif left_sensor < 500 and right_sensor > 500: |
|          turn_left()                     |
|      elif left_sensor > 500 and right_sensor < 500: |
|          turn_right()                    |
|      else:                               |
|          stop()                          |
|                                        |
|  This program makes the robot follow a   |
|  line by comparing two sensor readings.  |
+------------------------------------------+

Mini summary: A line‑following program uses sensors and motor control to keep a robot on a line.

Lesson 12: Uploading Code to a Robot

Definition: Uploading means sending the program from your computer to the robot's controller (like Arduino or micro:bit).

Why it's important: The robot needs the program to work. Uploading is how you put the program into the robot's brain.

Simple explanation: Uploading is like copying a recipe from a book into the robot's memory.

Real‑life example: You connect a micro:bit to a computer with a USB cable and press "upload."

School example: Students upload programs to their robots during class.

Home example: You upload a program to a robot kit to test it.

Nigerian example: Nigerian robotics teams upload code to their robots before competitions.

+------------------------------------------+
|      Uploading Code                       |
|------------------------------------------+
|  Computer                              |
|     |                                   |
|     |  USB Cable                        |
|     |                                   |
|     v                                   |
|  Robot Controller (Arduino/micro:bit)   |
|     |                                   |
|     v                                   |
|  The program is copied into the robot's |
|  memory. The robot now follows the      |
|  instructions in the program.           |
+------------------------------------------+

Mini summary: Uploading sends your program from the computer to the robot. The robot then follows your instructions.

Lesson 13: Debugging – Fixing Mistakes

Definition: Debugging is the process of finding and fixing errors (called "bugs") in a program.

Why it's important: Programs often have mistakes. Debugging is how you make them work correctly.

Simple explanation: Debugging is like being a detective. You look for clues to find the problem and fix it.

Real‑life example: If a robot moves left instead of right, you check the code and find the motor pins are swapped.

School example: A student finds a bug in their Scratch game and fixes it.

Home example: A robot doesn't stop at the line – you check the code and add a condition.

Nigerian example: A robotics team tests their robot and finds a sensor reading issue – they debug it.

+------------------------------------------+
|      Debugging Steps                      |
|------------------------------------------+
|  1. Observe the problem                   |
|     (Robot is not turning)                |
|  2. Check the code                        |
|     (Look at the turn instruction)        |
|  3. Identify the bug                      |
|     (The turn angle is too small)         |
|  4. Fix the bug                           |
|     (Change the angle)                    |
|  5. Test again                            |
|     (Robot now turns correctly)           |
|  6. Repeat if needed                      |
+------------------------------------------+

Mini summary: Debugging is finding and fixing mistakes in a program. It is part of every programmer's job.

Lesson 14: Robotics Programming Languages – Overview

Definition: A programming language is the set of words, symbols, and rules used to write programs. Different robots use different languages.

Why it's important: Knowing different languages helps you program different robots.

Simple explanation: Programming languages are like human languages – English, French, Yoruba. Robots understand different ones.

Real‑life example: Arduino uses C++. micro:bit uses Python or Blocks. LEGO robots use their own language.

School example: Students learn Scratch first, then Python.

Home example: A robot kit might use a simplified version of Python.

Nigerian example: Nigerian university students learn C, C++, and Python for robotics.

+------------------------------------------+
|      Common Robot Programming Languages   |
|------------------------------------------+
|  - Scratch: Visual blocks, beginners      |
|  - Python: Text-based, easy to learn      |
|  - C++: Text-based, fast and powerful     |
|  - Arduino: Based on C/C++                |
|  - Blockly: Visual, like Scratch          |
|  - MakeCode: Visual for micro:bit         |
|                                        |
|  Each language has its own strengths.     |
+------------------------------------------+

Mini summary: Different robots use different programming languages. Scratch and Python are good for beginners.

Lesson 15: Review – What We Learned

In this module, we learned how to program robots. We discovered that programming is giving a robot instructions. We explored visual programming with blocks and text‑based programming with code. We learned about sequence (order of instructions), loops (repeating instructions), conditions (making decisions), and variables (storing information). We wrote programs to move motors, read sensors, and even follow a line. We also learned about uploading code and debugging. You now have the skills to bring your robot to life with code!

Key Vocabulary (Simple Definitions)

  • Programming: Giving instructions to a robot.
  • Visual programming: Programming with blocks that snap together.
  • Text‑based programming: Programming by typing words and symbols.
  • Instruction: A single command for a robot.
  • Sequence: The order in which instructions are followed.
  • Loop: Repeating instructions.
  • Condition: A rule that checks if something is true or false.
  • Variable: A box that stores information.
  • Upload: Sending a program from a computer to a robot.
  • Debug: Finding and fixing mistakes in a program.

Important Concepts

Concept 1: Programming is giving instructions. Without instructions, a robot does nothing.

Concept 2: Sequence matters. The order of instructions changes what the robot does.

Concept 3: Loops save time. Use loops to repeat instructions instead of writing them many times.

Concept 4: Conditions make robots smart. They let robots react to the world.

Concept 5: Debugging is normal. All programmers make mistakes. Fixing them is part of the process.

Step‑by‑Step Explanations

How to write a program to make a robot move in a square:

  1. Set up the motor pins (e.g., pin 0 and pin 1 for left motor, pin 2 and pin 3 for right motor).
  2. Write a "move_forward" function that sets both motors to spin forward.
  3. Write a "turn_right" function that sets one motor forward and the other backward.
  4. Write a "stop" function that stops both motors.
  5. Write the main program: move forward 5 seconds, turn right, move forward 5 seconds, turn right, etc. Repeat 4 times.
  6. Upload the program to the robot and test it.

How to debug a program:

  1. Watch the robot and note what it does wrong.
  2. Look at the code and find the part that controls that action.
  3. Check for common errors: wrong pins, wrong values, missing conditions.
  4. Change one thing at a time and test again.
  5. Repeat until the robot works as expected.

Real‑life Examples

We've seen many real‑life examples in the lessons, such as washing machine programs, thermostats, self‑driving cars, factory robots, and delivery robots. These show how programming powers the robots around us.

Nigerian Examples

In Nigeria, students and engineers are writing programs for drones, farm robots, and delivery robots. Nigerian robotics teams are competing internationally, writing code in Python and C++. Learning to program robots opens up many opportunities in Nigeria's growing technology sector.

Fun Examples Children Can Relate To

Imagine you are the director of a robot show. Your robot is the dancer. You write a program that tells the robot to: "move left, spin, move right, wave, repeat." The robot performs the dance perfectly every time!

Another fun example: You write a program that makes a robot sing a song. The program tells the robot to beep at different times and for different lengths. You have made a robot musician!

Everyday Examples

  • A traffic light controller uses a program: "red for 30 seconds, green for 30 seconds, yellow for 5 seconds, repeat."
  • A dishwasher uses a program: "wash, rinse, dry."
  • A microwave uses a program: "heat for 2 minutes, then beep."

Teacher Notes

Key points: Emphasise that programming is about giving clear, step‑by‑step instructions. Use analogies like recipes and dance routines. Start with visual programming (like Scratch) before moving to text‑based. Encourage students to experiment and make mistakes – that's how they learn.

Activity idea: Have students write a program (in Scratch or pseudocode) to make a robot navigate a simple maze.

Parent Tips

Parents can help children learn programming by exploring Scratch or Blockly together. Support them in making mistakes and debugging. Encourage them to think step‑by‑step. Celebrate their successes. There are many online resources and robot kits that are perfect for beginners.

Interesting Facts

  • The first computer program was written by Ada Lovelace in 1843.
  • Scratch, the visual programming language, was created at MIT.
  • Python is named after the British comedy group Monty Python.
  • The average robot program has between 50 and 500 lines of code.

Did You Know?

Did you know that the code for self‑driving cars can have millions of lines of code? That's a lot of instructions!

Did you know that the first robot to be programmed was called "Unimate" and was used in a car factory in 1961?

Remember This

  • Programming is giving a robot instructions.
  • Visual programming (blocks) is great for beginners.
  • Text‑based programming (typing) is more powerful.
  • Instructions are followed in sequence (order matters).
  • Loops repeat instructions.
  • Conditions let robots make decisions.
  • Variables store information.
  • Uploading sends the program to the robot.
  • Debugging is finding and fixing mistakes.

Common Mistakes

  • Forgetting to add a loop – the program runs once and stops.
  • Putting instructions in the wrong order – the robot does the wrong thing.
  • Not reading the sensor correctly – the robot doesn't react properly.
  • Writing code for the wrong motor pins – the robot moves unexpectedly.
  • Forgetting to upload the new code – the robot runs an old program.

Best Practices

  • Start with a simple program and add complexity slowly.
  • Test your program in small parts (test motors first, then sensors).
  • Write clear code with comments (notes) to explain what it does.
  • Use meaningful variable names (like "light_level" instead of "x").
  • Make one change at a time when debugging.
  • Save your programs often and keep backups.

Illustrations

+------------------------------------------+
|      Programming Flowchart                |
|------------------------------------------+
|   +-------------------+                    |
|   |   Start Program   |                    |
|   +-------------------+                    |
|          ↓                                 |
|   +-------------------+                    |
|   |   Read Sensors    |                    |
|   +-------------------+                    |
|          ↓                                 |
|   +-------------------+                    |
|   |   Process Data    |                    |
|   +-------------------+                    |
|          ↓                                 |
|   +-------------------+                    |
|   |   Make Decision   |                    |
|   +-------------------+                    |
|          ↓                                 |
|   +-------------------+                    |
|   |   Send to Motors  |                    |
|   +-------------------+                    |
|          ↓                                 |
|   +-------------------+                    |
|   |   Repeat Loop     |--------------------+
|   +-------------------+                    |
|                                        |
|  This is the basic cycle of a robot     |
|  program: sense, think, act, repeat.    |
+------------------------------------------+

+------------------------------------------+
|     Line-Following Robot Program          |
|------------------------------------------+
|   Start                                    |
|      ↓                                     |
|   Read left sensor                         |
|      ↓                                     |
|   Read right sensor                        |
|      ↓                                     |
|   Are both on line? Yes → Move forward    |
|   Is left off line? Yes → Turn left       |
|   Is right off line? Yes → Turn right     |
|      ↓                                     |
|   Go back to "Read left sensor"           |
|                                        |
|  This flowchart shows the program logic   |
|  for a line‑following robot.              |
+------------------------------------------+

Comparison Tables

FeatureVisual ProgrammingText‑Based Programming
How it worksBlocks snap togetherTyped words and symbols
Ease of learningVery easyHarder
PowerLimitedVery powerful
ExampleScratch, BlocklyPython, C++, Java
Best forBeginners, kidsProfessionals, advanced

ConceptWhat it doesExample
SequenceFollows instructions in orderStep 1, Step 2, Step 3
LoopRepeats instructionsforever: move_forward()
ConditionMakes a decisionIF light > 50 THEN turn
VariableStores informationcount = 5

End‑of‑Module Summary

In this module, we learned the essential skill of programming for robotics. We discovered that programming is giving a robot instructions to follow. We explored visual programming using blocks and text‑based programming using code. We learned about sequence (the order of instructions), loops (repeating instructions), conditions (making decisions), and variables (storing information). We wrote simple programs to make motors move and sensors read data. We created a line‑following robot program, learned how to upload code, and how to debug mistakes. You now have the power to bring any robot to life with code. Keep practicing and experimenting – the more you program, the better you become!

Frequently Asked Questions (10)

  1. What is programming? Giving instructions to a robot.
  2. What is the easiest programming language for robots? Scratch or Blockly for beginners.
  3. What is the difference between visual and text‑based programming? Visual uses blocks, text‑based uses typed code.
  4. What is a loop? A way to repeat instructions.
  5. What is a condition? A rule that checks if something is true or false.
  6. What is a variable? A box that stores information.
  7. How do I send my program to the robot? Upload it through a USB cable.
  8. What if my robot doesn't work? Check your code for bugs and debug it.
  9. What language do robots use? Many – Scratch, Python, C++, etc.
  10. Can I program a robot without a computer? Some robots have built‑in screens, but most need a computer.

Review Questions (15)

  1. What is programming?
  2. What is the difference between visual and text‑based programming?
  3. What is a sequence?
  4. Why does the order of instructions matter?
  5. What is a loop?
  6. Give an example of when you would use a loop.
  7. What is a condition?
  8. What is an "IF-THEN" statement?
  9. What is a variable?
  10. Why are variables useful?
  11. What does it mean to "upload" a program?
  12. What is debugging?
  13. Name two programming languages used for robots.
  14. What does a line‑following program do?
  15. What should you do if your robot doesn't work as expected?

Fill‑in‑the‑Blank Exercises

  1. __________ is giving a robot instructions to follow.
  2. A __________ is a way to repeat instructions.
  3. A __________ is a rule that checks if something is true or false.
  4. A __________ is a box that stores information.
  5. __________ is sending a program from a computer to a robot.

True or False Exercises

  1. Programming is not important for robots. (False)
  2. Visual programming uses blocks that snap together. (True)
  3. Text‑based programming is easier than visual programming. (False)
  4. A loop repeats instructions. (True)
  5. Debugging is only for professional programmers. (False)

Multiple Choice Questions (15)

  1. What is programming?
    A) Building a robot
    B) Giving instructions to a robot
    C) Powering a robot
    D) Cleaning a robot
    Answer: B
  2. What is visual programming?
    A) Programming with pictures
    B) Programming with blocks
    C) Programming with music
    D) Programming with video
    Answer: B
  3. What is an example of a visual programming language?
    A) Python
    B) Scratch
    C) C++
    D) Java
    Answer: B
  4. What is a sequence?
    A) Repeating instructions
    B) The order of instructions
    C) Storing information
    D) Making decisions
    Answer: B
  5. What does a loop do?
    A) Runs once
    B) Repeats instructions
    C) Makes decisions
    D) Stores data
    Answer: B
  6. What is a condition?
    A) A type of loop
    B) A rule that checks true/false
    C) A variable
    D) An instruction
    Answer: B
  7. What does "IF-THEN" do?
    A) Repeats code
    B) Makes a decision
    C) Stores a value
    D) Moves the robot
    Answer: B
  8. What is a variable?
    A) An instruction
    B) A box that stores information
    C) A type of sensor
    D) A motor
    Answer: B
  9. What does "upload" mean?
    A) Download from the robot
    B) Send code to the robot
    C) Delete code
    D) Save a file
    Answer: B
  10. What is debugging?
    A) Testing the robot
    B) Finding and fixing mistakes
    C) Building the robot
    D) Uploading code
    Answer: B
  11. Which language is text‑based?
    A) Scratch
    B) Blockly
    C) Python
    D) All of the above
    Answer: C
  12. What does a line‑following robot use to follow a line?
    A) A camera
    B) A light sensor
    C) A touch sensor
    D) A microphone
    Answer: B
  13. What is the first step in debugging?
    A) Fix the code
    B) Upload again
    C) Observe the problem
    D) Delete the code
    Answer: C
  14. What happens if you don't include a loop in a program?
    A) The program runs forever
    B) The program runs once and stops
    C) The robot moves faster
    D) The robot won't move
    Answer: B
  15. What does "else" do in a condition?
    A) Runs if the condition is true
    B) Runs if the condition is false
    C) Repeats code
    D) Stores a value
    Answer: B

Matching Exercises

Match the term with its definition.

TermDefinition
Loopa) The order of instructions
Conditionb) Repeats instructions
Variablec) Makes a decision
Sequenced) Stores information
Debugginge) Finding and fixing mistakes

Answers: Loop – b, Condition – c, Variable – d, Sequence – a, Debugging – e

Short Answer Questions

  1. What is the difference between visual programming and text‑based programming?
  2. Why is the order of instructions important in a program?
  3. Give an example of a situation where you would use a loop.
  4. What is an "IF-THEN" statement and how is it used?
  5. Explain the steps you would take to debug a program.

Scenario‑based Exercises

Scenario 1: You have a robot that should move forward for 3 seconds, then turn right, then move forward for another 3 seconds. Instead, it moves forward for 3 seconds, then turns left. What might be wrong with the program?

Scenario 2: You are programming a robot to follow a line. The robot keeps going straight even when the line curves. What part of the program might be incorrect?

Group Activity

"Program a Robot Dance" – In groups of 4, write a program (in Scratch or pseudocode) to make a robot perform a dance. It should include at least 5 different moves, a loop, and a condition. Present your dance to the class.

Individual Activity

Write a simple program in pseudocode for a robot that avoids obstacles. The robot should move forward, and if it sees an obstacle (using a touch sensor), it should turn left and continue.

Classroom Discussion Questions

  1. Why do you think programming is important for robots?
  2. What do you find most challenging about programming?
  3. How do you think programming will change in the future?
  4. What are some ways you can use programming to help your community?

Mini Project

"Build a Simple Robot Program" – Design a program for a robot that can navigate a 2‑meter square track. The robot should start at the beginning, go around the track, and return to the start. Write the program in pseudocode or Scratch.

Practical Assignment

Use a robot kit (like micro:bit or Arduino) to write a program that makes the robot move forward, then stop when it encounters an obstacle (use a touch sensor or distance sensor). Upload the program and test it.

Challenge Exercise

"Line‑Following Challenge" – Write a program that makes a robot follow a line. The line should have a 90‑degree turn. The robot must successfully follow the entire track. Use two light sensors for better accuracy.

Key Takeaways

  • Programming is giving a robot instructions.
  • Visual programming uses blocks (Scratch, Blockly).
  • Text‑based programming uses typed code (Python, C++).
  • Sequence is the order of instructions.
  • Loops repeat instructions.
  • Conditions let robots make decisions (IF-THEN).
  • Variables store information.
  • Uploading sends code to the robot.
  • Debugging is finding and fixing mistakes.
  • Programming is fun and powerful – keep practicing!

Preparation for the Next Module

In Module 4, we will dive into Sensors and Actuators in Depth. You will learn about different types of sensors (light, ultrasonic, touch, sound) and actuators (motors, servos, LEDs) in detail. We will explore how to choose the right sensor for the right task and how to connect them to your robot. You'll also learn advanced techniques like sensor calibration and using multiple sensors together. Get ready to make your robot even smarter!

🏆 Get Certified

🔒

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

🎓 Sign Up to Get Certified
🛠️ Practice Tools
Hands-on simulators & labs - subscription required.
→
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
→