X
Home > Blog > STEM for Arduino > HOW to Detect Air Pressure with Kidsuno

HOW to Detect Air Pressure with Kidsuno

By r November 7th, 2024 43 views
The station monitors air pressure in real time. When the air pressure is in normal range, the green LED lights up; When it is in the low range, the yellow LED turns on; When it is high, the red LED is on.
In this experiment, we use an LPS331APTR air pressure sensor and a traffic light module to reveal the air pressure. LED will light up in corresponding colors when the pressure value is in the related set range.

Flow

4701

Assembly

line1

Required Parts

47_00

line1

Step 1

47_01

line1

Step 2

47_02

line1

Step 3

47_03

line1

Step 4

47_04

line1

Step 5

47_05

line1

Step 6

47_06

line1

Step 7

47_07

line1

Step 8

47_08

line1

Step 9

47_09

line1

Completed

47_10

line1

Wiring Diagram

4702

Test Code

Open KidsBlock and connect the board to your computer. Click File –> Load from your computer.

3111

Choose D:\Code\1.Code_kidsuno to open 4.7Air pressure detection.sb3 file.

4703

Click Unconnectedto connect to port and then 2210.

Explanations

5top

Conceive:

Generally, air pressure within 950hPa ~ 1050hPa is regared as the normal range. If the pressure is lower than 950hPa or higher than 1050hPa, human may have a headache or dizziness, and even some meteorological disasters will happen.

Set 950 and 1050 as two thresholds to divide the pressure into three ranges.

  • low pressure: lower than 950hPa

  • normal pressure: 950hPa ~ 1050hPa

  • high pressure: higher than 1050hPa

LED will light up in corresponding colors when the pressure value is in the related set range.

  • Within low pressure range: the yellow LED lights up.

  • Within normal pressure range: the green LED lights up.

  • Within high pressure range: the red LED lights up.

line2

Code structure:

  1. Initialization. set the pins of LPS331APTR air pressure sensor and the traffic light module.

    4704

  2. Loop.

    LPS331APTR sensor reads the air pressure value and outputs it.

    Determine which range of the pressure value is in, in order to turn of related LED.

    • air pressure > 1050hPa: the red LED lights up and other two LEDs goes off.

    • air pressure < 950hPa: the yellow LED lights up and other two LEDs goes off.

    • 950hPa < air pressure < 1050hPa: the green LED lights up and other two LEDs goes off.

    4705

5bottom

Test Result
4top
After uploading the code, the LPS331APTR sensor measures the air pressure.
When the air pressure is in normal range, the green LED lights up;
When the air pressure is in the low range, the yellow LED lights up;
When the air pressure is in the high range, the res LED turns on.
4706
4bottom
HOW to Detect Ultraviolet Index with Kidsuno
Previous
HOW to Detect Ultraviolet Index with Kidsuno
Read More
HOW to Make a Track Alarm with KidsIOT
Next
HOW to Make a Track Alarm with KidsIOT
Read More
Message Us