agsdix-fas fa-child

Fall detector

A fall detector has various applications. For example, it’s common for elderly individuals to fall, and a fall detector could be used to monitor them and respond promptly.

info outline icon
Basic Activity; Accelerometer; Absolute Value; Events; Parameter Management.

What are we going to do?

Are you a teacher?

Lesson Plan

Courses

  • Grades 3-12
  • Courses from 3rd grade to 12th grade

Materials

  • Cellphone, tablet, or computer
  • Internet connection

Description

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

Educational Objectives

  • Understand the concepts of “if-else” and “Cartesian plane.”
  • Create a technological object (prototype) using a device.
  • Identify relationships between technology and the surrounding world.
  • Evaluate personal work and the work of others in individual or team tasks.
  • Engage in dialogue and reflection on improvement ideas.

Start (10 minutes)

Welcome the students to the class and briefly introduce the day’s activity: “Today we will learn to prototype a ‘fall detector’.”

We will start the class by providing technical knowledge to the students for meaningful learning of the practical activity.

To begin the class, we can start with a question:

Do you remember what conditionals are in programming?

You can let the students propose their answers and then supplement with the correct answer.

It’s a way to instruct the computer to do different things depending on whether something is true or false.

For example, you can tell the computer to turn off the light if it’s daytime, and if not, turn it on.

If you have doubts, you can review conditionals “if-then-else” in activity 9.

But what if we want to add more than two options?

Give them time to inquire and propose answers. Then, add:

The “elif” structure is a way to add more options to a decision being made in the “if-then-else” structure. You can think of this as choosing between different paths.

For example: imagine you have to feed your dog, and depending on the time of day, you’ll decide whether to give breakfast, lunch, or dinner.

  • IF it’s before 9:00 am, THEN you have to give breakfast.
  • ELIF it’s between 9:00 am and 6:00 pm, THEN you have to give lunch.
  • ELSE it’s at a different time, THEN you have to give dinner.

“Elif” is used to choose between different options based on different conditions. If one condition is true, then the computer will do one thing. If another condition is true, then the computer will do something else. And so on, following the order you programmed it (sequence).

Finally, to initiate the prototyping process and make them feel like protagonists of their learning, ask them:

Do you want to learn to prototype a fall detector?

Before prototyping, you can review the complementary content:

The Cartesian plane is a way to represent different positions in a two-dimensional space using two perpendicular lines that intersect at a point. These lines are called axes and are labeled with the letters X and Y.

You may have seen it used to represent two different values on a graph, and today we will use it to represent up-and-down movement, i.e., on the Y-axis.

Development (20-30 minutes)

We will connect our equipment to the Protobject platform. For this exercise, we will use the motion sensor SMARTPHONEMOTION and the lamp LAMP.

Remember to experiment on your own before asking the students to experiment with Protobject in this way. This way, you can anticipate questions that may arise from the students.

First, we will program it to tell our monitor that if the movement on the Y-axis is less than 6, the green light should turn on.

We will repeat the same steps for the yellow light with movement less than 20 and the orange light with movement less than 40. Finally, we use an ELSE-IF (“SINOSI”) statement to indicate that if none of the other conditions are met, the red light should turn on.

Finally, we will place everything inside a loop to repeat the condition indefinitely.

To test the prototype, tell the students to click the activation button.

Congratulations!

Closure (5-10 minutes)

Now that you have prototyped a fall detector with Protobject, challenge your students with a question:

  • What would happen if we changed the Y-axis to the X-axis?

To solve the problem posed at the end of the activity, simply remember that color is represented using the three primary colors: Red, Green, and Blue. You can use the value of each axis of the Accelerometer to control each primary color. This way, if you move the phone in a direction, the light will turn on with the respective colors.

Check the challenge solution.

agsdix-fas fa-book-reader

Learn

Do you remember how an accelerometer works?

In the previous activity, we used the accelerometer to detect the tilt of a frame.

The accelerometer is a sensor that detects accelerations in three directions: left-right, forward-backward, and up-down. When the phone is still, the accelerometer detects gravity’s force.

If you shake the phone, the accelerometer will detect changes in motion and the direction in which the phone is moving. This means we can use the accelerometer to determine if there are variations in the phone’s acceleration and in which direction.

To detect falls, it is not necessary to know which direction the phone is moving. What matters is the variation in the phone’s acceleration.

When the phone moves suddenly, such as when it falls to the ground, there is a sharp change in acceleration. It is this sudden change in acceleration that indicates the phone has fallen.

To calculate the overall acceleration of the phone, we take the absolute value of acceleration in each direction and add them together. This way, it doesn’t matter in which direction the phone falls; it only matters that it falls.

Let's get to work!

At the beginning of the process, the sum of the absolute values of the X, Y, and Z axes will be carried out. Protobject does this automatically through the ‘generalMotion’ variable. Then, we will set a detection threshold to determine if the device has experienced a fall. To achieve this, we have determined that if the total acceleration derived from the three axes exceeds 150, it will trigger a predefined sound activation. The selection of this sound can be done through a YouTube link.

Make

Let’s create a prototype to detect falls.

The first step is to add two devices that allow us (1) to detect smartphone movements and (2) to play sounds.

1

Press Add device and select Motion

2

Click on DevicesAdd device and select AudioPlayer

plus square icon

Tip: In Protobject, you can add more components on the same smartphone by pressing the SCAN button as many times as you need.

We are ready to start prototyping!

Code composition

Click on the question circle icon to open the comments that explain the code.

Note: This code uses the ‘movimientoGeneral’ variable, which automatically sums the absolute values of the X, Y, and Z axes. Try modifying the code to perform this sum manually through the code, instead of using the ‘movimientoGeneral’ variable.”

agsdi-bulb-options

Reflect

Now that you’ve created a fall sensor with Protobject

How reliable do you think this device is?
Would you use it in a real-life situation?

plus square icon

Challenge: Create a light that changes colors based on the phone’s accelerations.

Hint: Each primary color has to receive values from the 3 different axes of the accelerometer (X, Y, and Z). Use an event to detect changes in the accelerometer.