Back to activities
Grades 6-8
7, 8
test
Author:

Tomasz MikołajczykPETE

Nested loop

programming • Computer Science (CS)
Robots:
x1
Programming interface:
Photon Code
alt
Back to activities
Scenario Image
Download
Share
Share

Required items:

  • x1 PC computer for each participant (for larger groups pair up students)
  • x1 Tape measure
  • An obstacle - an empty box (e.g., a juice carton)

Lesson scenario:

Preparation:

  • Extend the tape measure on the computer lab’s floor
  • Place the robot at the beginning of the tape (0cm position).

Main activity:

Students must have the basic knowledge of visual programming (using programming blocks) in the Photon Coding app.

Describe the task:

  • We will test the robot’s built-in distance sensor — depending on the distance between the robot and an obstacle, the robot’s eyes and ears (LED lights) should change their color.
  • By default, the eyes and ears are white. The robot should also greet the user upon startup (a sort of system initialization confirmation; you can use any sound).
  • To present results, let’s use the traffic lights color pattern:
    • An obstacle in immediate proximity to the robot (less than 10 cm) — the LEDs turn red.
    • An obstacle in a safe distance from the robot (more than 10 cm, less than 50 cm) — the LEDs turn orange.
    • An obstacle far away from the robot (more than 50 cm, less than 70 cm) – the LEDs turn green.
    • In all other cases, the LED lights should stay white.
  • Please ask students to pay special attention to the order of conditions. These conditions could also be nested (one in the other).
  • During the exercise, to prevent programming progress loss and develop a good habit, students should save their work regularly - use the Save (floppy disk) icon in the Photon Coding app.
  • Each student (or a pair) can test their program. Please provide them with the Magic Dongle, connect the robot to their workstation, put an obstacle in several spots (further and closer each time), and test the program. Please make sure students compare their program’s performance with the initial concept. Additionally, ask them to check the accuracy of the distance reading.

 

Sample solution:

 

Interesting facts / Questions time

Ask students to check if the 70 cm distance away from the robot is precisely the same (70 cm) if they use the tape measure. If there is a discrepancy, how can they explain it? How do we call such a phenomenon in physics?
(Answer: it is called the observational error or measurement error).

Discussion (No comments)

Log in to start a discussion