agsdix-fas fa-child

Device for counting people

Sometimes it’s necessary to count people, for example… to adhere to the capacity limit at a concert! We’re going to create a device for counting the people entering a place.

Info outline icon
Basic Activity; Events; Conditionals; Variables; Differences between events and main loop.

What are we going to do?

Are you a teacher?

Lesson Plan

Courses

  • Grades 3-12
  • 3rd Grade – 12th Grade Courses

Materials

  • Cell phone, tablet, or computer
  • Internet connection

Description

In this activity, students can experiment in an introductory manner with Protobject, learning visual programming and computer science with a device in a safe and playful way.

Educational Objectives

  • Understand the concepts of “event” and “numeric data.”
  • Create a technological object (prototype) using a device.
  • Identify relationships between technology and the world around them.
  • Evaluate personal and others’ work in individual or team tasks.
  • Discuss and reflect on ideas for improvement.

Beginning (10 minutes)

Welcome the students to the class and briefly introduce the day’s activity: “Today, we will learn to prototype a people counter.”
We will start the class by providing technical knowledge to the students for meaningful learning of the practical activity.
To start the class, we can begin with a question:
What is a counting device?
You can give the students the opportunity to propose their answers and then complement with the correct response.
A counter is a tool used to count the quantity of elements that enter a system.
It can be used to count the quantity of purchased products, the number of activities performed, the number of laps run, or, for example, the number of people entering a place.
Every time someone enters, you press the corresponding button, and the counter increases by one.
The counter is a screen that shows the current number of people in the place. It’s like keeping track of visitors.
What could a people counter be used for?
You can give the students the opportunity to propose their answers and then complement with the correct response.
A people counter can be useful in various situations.
For example, in stores to record user interest at specific points, at events to control venue capacity, or in public transportation to plan service and improve efficiency.
In summary, a people counter is a tool for keeping track of people in a place and improving efficiency, safety, and the user experience.
For this activity, we will use two concepts: events and variables.
A variable is like a box where you can store a value, such as the number of people in a place at a given moment.
If we want to know how many people have entered, we can store the current number of people in a variable and update it each time someone enters.
This way, we will always have the correct number of people at all times.
An event is like a signal that occurs when something happens, for example, when you press a button, an event is generated.
When you perform an action, the computer recognizes this action as an event and responds in a specific way to what you have just done.
In this case, the event is pressing the button, and the action will be to add 1 to the counter.
Finally, to start the prototyping process and make them feel like the protagonists of their learning, ask them:
Do you want to learn how to prototype a people counter?

Development (20-30 minutes)

We connect our device to the Protobject platform. For this exercise, we will use the motion sensor DIBUJARESCRIBIR and BOTONTACTIL.
Remember to experiment on your own before asking the students to experiment with Protobject. This way, you can anticipate any questions that may arise from the students.
We will start by assigning the value 0 to the counter and call the variable COUNT. You can use a different name if you prefer.
Next, we will instruct the screen to display the value of that variable so that even as the number changes, you will always be able to see it on the screen.
Then, we will tell them that when the button is pressed, the value of the variable will change, increasing by 1. For example, if it was 0, it will become 1, and if it was 125, it will become 126.
To test the prototype, we will instruct the students to click on the activation button.
Congratulations!

Closure (5-10 minutes)

Now that you have prototyped a motion sensor with Protobject, challenge the students with a question:

  • What would happen if we used a loop instead of a variable?

Then, you can leave them with a challenge as homework or, if you have time in the same class.

  • So, how do we activate an exit button in addition to an entrance button?
agsdix-fas fa-book-reader

Learn

What is a counting device?

A counting device is a tool used to count the quantity of elements entering a system.

For example, it could be used to count the number of products purchased, the quantity of activities performed, the number of laps you have run, or the number of people entering a place.

In the latter case, each time someone enters, you can press the corresponding button, and the counter increases by one.

The counter is a display that shows the current number of people in the place. It’s like keeping track of visitors.

What is the purpose of a people counter?

A people counter can be useful in various situations.

For example, in stores to record user interest at specific points, at events to control venue capacity, or in public transportation to plan service and improve efficiency.

In summary, a people counter is a tool to keep track of the number of people in a place and improve efficiency, safety, and user experience.

We use a variable to keep track of the number of people

Do you remember variables? If you don’t recall what a variable is, you can review activity 7.

A variable is like a box where you can store a value, such as the number of people in a place at a given moment.

If we want to know how many people have entered, we can store the current number of people in a variable and update it each time someone enters.

This way, we will always have the correct number of people at all times.

And how do we know if the button was pressed?

Do you remember what an event is?

An event is a signal that gets triggered when something happens. For example, when you press a button, it sends a signal that it was pressed. That’s an event!

When you perform an action, the computer recognizes this action as an event and responds in a specific way to what you have just done.

In this case, the event is pressing the button, and the action is to add 1 to the counter.

Let’s get to work!

In this code, we will initialize the counter at 0. Every time we press the button, 1 will be added to the counter to keep a total record of people. How do we achieve this? It’s simple: we will instruct the variable to increase by 1 and then clear the screen to display the new value of the variable.

Make

We are going to create the prototype that allows us to count people entering a place.

The first step is to add two devices that allow us to (1) display the number of people and (2) increase the number of people.

1

Press Add device and select WriteDraw, the device where we will display the number of people.

2

Press DevicesAdd device and select TouchButton to create the button to increase the number of people.

3

Remember that if you don’t have smartphones to scan the QR codes, you can press Open in this window to open the components on the same computer.

We are ready to start prototyping!

Code composition

Click on question circle icon to open the comments explaining the code.
agsdi-bulb-options

Reflect

What if we use a main loop instead of an event? Give it a try!

agsdi-bulb-options

Challenge

What do we do if, in addition to counting the people who enter, we want to count those who exit to have an updated count at all times?

Tips: How can we add another button to the counter?

In the next activity, we will learn how to control the volume of a song!