X
Home > Blog > STEM for Arduino > HOW to Detect Magnetic Field with Kidsuno

HOW to Detect Magnetic Field with Kidsuno

By r November 1st, 2024 44 views
After the lightning strike, a certain amount of electricity will generated in the surrounding, and a strong magnetic field will be produced in an instant.
This magnetic field interferes with the connection of the relevant equipment of the station, thus disabling the automatic devices. Therefore, it is necessary to detect the magnetic field at all times and alarm immediately when the magnetic field is detected.
In this experiment, we utilize a Hall sensor and a white LED module to detect magnetic field. When the Hall sensor detects a magnetic field, the white LED lights up.

Flow

4301

Assembly

line1

Required Parts

43_00

line1

Step 1

43_01

line1

Step 2

43_02

line1

Step 3

43_03

line1

Step 4

43_04

line1

Step 5

43_05

line1

Step 6

43_06

line1

Step 7

43_07

line1

Completed

43_08

line1

Wiring Diagram

4302

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.3Magnetic field detection.sb3 file.

4303

Click Unconnectedto connect to port and then 2210.

Explanations

5top

Conceive:

When the Hall sensor detects a magnetic field, a low power(0) will be output, and the white LED lights up. If there is no magnetic field, high(1) will be output, and the LED goes off.

line2

Code structure:

  1. Initialization. Set the pins of the Hall sensor and the white LED module.

    4304

  2. Loop.

    Print the digital value of the power level of the Hall sensor.

    Determine whether the value equals 0 (0 means a magnetic field is detected).

    • value = 0: the white LED lights up.

    • value ≠ 0: the white LED goes off.

    4305

5bottom

Test Result
4top
After uploading the code, the Hall sensor starts to detect magnetic field.
If the sensor detects a magnetic field, the white LED will turn on. If not, the LED will go off.
4306
4bottom
HOW to Simulate a Fire Alarm with Kidsuno
Previous
HOW to Simulate a Fire Alarm 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