Digital Technologies · Algorithms, programming and robotics
Programming a robot: sequence and loops
Write a program of moves and turns to steer a robot to its goal, then shorten it with a loop.
- Curriculum: Digital Technologies, Algorithms, programming and robotics
- Class: JSS 1 – SSS 1
- For BECE, WAEC, NECO practicals
- Readings, table
- Quiz with answers explained
Start this experimentAll Digital Technologies experiments
Aim
To write, test and debug a simple program using sequence and iteration (loops).
Apparatus
- Floor robot or programmable buggy (or this simulator)
- Grid mat with obstacles
Theory
An algorithm is a step-by-step set of instructions. A program is an algorithm written so that a machine can follow it. The robot obeys three instructions: move forward one square, turn left, turn right.
Sequence means doing instructions in order. Iteration (a loop) repeats a set of instructions, so a pattern only has to be written once. Finding and fixing mistakes is called debugging.
Procedure
- Choose a level and study the grid: the robot must reach the flag without hitting a wall.
- Add instructions to the program. Pressing Forward again increases the count.
- Run the program. Every run is logged.
- If the robot crashes or stops short, debug the program and run it again.
- On levels 3 and 4, find the repeating pattern and use “repeat the whole program” to write a shorter solution.
What you do in the virtual lab
Set up the apparatus on screen, take readings and record them in a table (Level; Program; Repeats; Instructions written; Steps run; Result). Simulated instruments give slightly different readings each time, as real ones do. Finish with a short quiz; every answer is explained.
Teachers can set the experiment for a class, see each student’s results and use it as a WAEC- or NECO-style practical paper in exam practice.
Practice questions
A step-by-step set of instructions for solving a problem is called
- an algorithm
- a loop
- a bug
- hardware
Show the answer
A. an algorithm An algorithm is the plan; a program is the algorithm written for a computer.
Repeating a group of instructions several times is called
- sequence
- selection
- iteration
- debugging
Show the answer
C. iteration Iteration means looping. Selection means choosing between paths (if…else).
A robot facing north obeys: Turn right, Turn right, Turn right. It now faces
- north
- east
- south
- west
Show the answer
D. west North → east → south → west.
Related Digital Technologies experiments
- Logic gates and truth tablesSwitch the inputs of AND, OR, NOT, NAND, NOR and XOR gates and build each truth table.
- Binary, octal and hexadecimalFlip eight bit-switches to see how computers store numbers, then hit target values in binary.
- How strong is a password?Test made-up passwords, measure their strength in bits and see how long an attacker would need to guess them.
- Spreadsheet formulas and functionsUse cell references, SUM, AVERAGE, MAX and IF to complete a shop sales record and a class result sheet.
- Coding in PythonWrite real Python – print, variables, loops and if statements – and have each program checked automatically.
- Train a simple AITeach a computer to tell ripe plantain from unripe by giving it labelled examples, then test how accurate it is.