Skip to main content
Activity (Hands-On)Grades 6 - 8

Using Waits, Loops and Switches

Students are given a difficult challenge that requires they integrate what they have learned so far in the unit about wait blocks, loops and switches. They incorporate these tools into their programming of the LEGO® MINDSTORMS® robots to perform different tasks depending on input from two touch sensors. This activity helps students understand how similar logic is implemented for other every day device operations via computer programs. A PowerPoint® presentation, pre/post quizzes and worksheet are provided.

A photograph of an assembled LEGO MINDSTORMS EV3 robot.Programs involving loops, switches and wait blocks enable more efficient control of LEGO robots.

Programming tools similar to those that students build into their skill sets from this activity are incorporated into the programming that runs all sorts of devices we use every day. Many of these programs are designed to "wait" until a user does something, such as credit card readers waiting until a card is swiped. In addition, depending on what happens (new sensor input) the program behaves a certain way. For example, if the device was unable to read the card, it might display a message to try again. And once the task is completed with one card, the program "goes back" and gets ready to accept another card swipe. The card reader program is continuously in this loop and designed to respond to various sensory input.

After this activity, students should be able to:

  • Explain what loops and switches are.
  • Identify programming situations in which loops and switches should be utilized.
  • Write programs that utilize loops and switches.

More Like This