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
Assembly
Required Parts
Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Completed
Wiring Diagram
Test Code
Open KidsBlock and connect the board to your computer. Click File –> Load from your computer.
Choose D:\Code\1.Code_kidsuno to open 4.3Magnetic field detection.sb3 file.
Click to connect to port and then .
Explanations
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.
Code structure:
-
Initialization. Set the pins of the Hall sensor and the white LED module.
-
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).
Test Result
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.