Basic Activity; Main Loop; Timing.
What are we going to do?
Are you a teacher?
- Grades 3-12
- Courses 3rd grade – 12th grade
- Cell phone, tablet, or computer
- Internet connection
In this activity, students will have the opportunity to experiment with Protobject, a visual programming tool. They will learn programming and computer science concepts in a safe and fun way.
- Understand the concept of the Main Loop.
- Create a technological object (prototype) using a device.
- Identify relationships between technology and the surrounding environment.
- Evaluate their own and others’ work, both individually and in a team.
- Engage in dialogues and reflections to propose improvements.
Beginning (10 minutes)
Welcome the students and introduce the day’s activity.
Today, we will learn how to prototype a traffic light.
We will start the class by providing technical knowledge to the students for meaningful learning of the practical activity.
Begin the class with a question:
Do you remember how to time a LED?
Allow students to respond and then provide the correct answer. If necessary, show the previous code.
“When we wanted to time a LED, we assigned it a time to turn on and off. Now, we will assign colors!”
You can explain the order of the traffic light colors (red, yellow, and green) or challenge them to research it themselves by observing a real traffic light or searching online.
Next, present a challenge:
“What if we want the traffic light to operate for 1 hour?”
Let the students explore this question and then provide the answer.
“If we wanted to repeat this code every second for an hour, we would have to do it 3600 times. That would be a lot of code. This is where the concept of the ‘Main Loop’ comes into play.”
Explain what a “Main Loop” is:
“The ‘Main Loop’ consists of repeating the entire process indefinitely until we decide to stop it.”
Finally, to kickstart the prototyping process and make them feel like the protagonists of their learning, ask them:
Do you want to learn how to prototype a traffic light?
Development (20-30 minutes)
Connect the devices to the Protobject platform so that students can interact with the LEDs on the screen through programming commands.
Follow the steps in the “Prototyping” section on the platform. Ensure that you have experimented beforehand to anticipate students’ questions.
Closure (5-10 minutes)
Ask students how a traffic light works in real life.
“How many traffic lights are used at an intersection?”
“What is the main purpose of a traffic light?”
Explain that a pedestrian traffic light shows the red color to stop cars and then the green color to allow people to cross.
Finish by exciting them for the next exercise:
“In the next exercise, you will be the creators of your own traffic light!”
What happens if we make an LED lamp change to green, yellow, and red? We create a traffic light!
To do this, we need to time the lights and assign them colors!
But the code stops!
By executing the blocks in order, we will make the traffic light go from green to yellow and then red, finishing the program there. If you don’t remember how to change colors, you can check the previous activity.
To have the process repeat, we would need to start repeating the sequence so that after red comes another green, then yellow, red, green, yellow, red, and so on…
But what if we want the traffic light to operate for an hour? We would have a lot of repeated code!
What if we want the entire process to repeat on its own?
We use the main loop!
Here, the concept of the Main Loop comes into play!
This allows us to repeat all the program code until the user terminates it.
In this way, we can keep a sequence of blocks running indefinitely!
For example, using the Main Loop, we can continuously repeat the code that controls the traffic light.
Let’s get to work!
We are ready to start prototyping!
The loops are located in the category Loops
How does a traffic light work in real life?
How many traffic lights are used at an intersection?
What is the purpose of a traffic light?