Programming Robots
Download the Lessonotes Mobile Ghana app for faster lesson access on Android and iPhone.
Subject: Robotics
Class: SHS 1
Term: 2nd Term
Week: 20
Grade code: 1.3.3.LI.3
Strand code: 3
Sub-strand code: 3
Content standard code: 1.3.3.CS.1
Indicator code: 1.3.3.LI.3
Theme: Robot Construction & Programming
Subtheme: Programming Robots
This page supports the lesson note with a companion video and a short classroom-ready summary.
For class groups and homework, share this lesson page so learners also get the summary, objectives, and full lesson context.
Welcome, learners! Today, we are moving from designing the logic of a robot to actually writing the instructions that bring it to life. We will learn how to make a robot react to its environment using a powerful programming tool called a "feedback loop." Think about a smart fan that slows down when the room gets cold, or an automatic light that turns on only when it's dark. These systems use feedback to make decisions. We will learn how to program these "smart" behaviours by converting a plan (a flowchart) into code.
This lesson builds on our previous knowledge of basic programming. Let's break down the key ideas for today. A. Quick Revision: Flow of Control In programming, "flow of control" is the order in which the computer executes statements. We know three basic types: Sequence: Instructions are executed one after another, in the order they are written. Selection: A choice is made based on a condition (e.g., `if-else` statements). The program does one thing if the condition is true, and something else if it is false. Iteration (Loops): A block of code is repeated as long as a certain condition is true (e.g., `for` loops, `while` loops).
Today, we focus on making our loops "smarter" by using feedback from the real world. B. What is a Controlled Feedback Loop? This might sound complex, but the idea is simple and very powerful. Let's break it down: Loop: A piece of code that repeats. A `while` loop is perfect for this. It repeats *while* a condition is true. Feedback: This is information or data that a robot gets from its environment using sensors. Examples include: An ultrasonic sensor measuring distance. A Light Dependent Resistor (LDR) measuring brightness. A push button detecting a press. A line-following sensor detecting a black or white line. Controlled Feedback Loop: This is a loop where the condition for repeating depends on the feedback from a sensor. The robot is in a continuous cycle of *acting*, *sensing*, and *deciding* whether to continue.