PIR Motion Sensor
CONTEN TS
Let’s set up the Mind+ programming environment for Bittle and use the coding blocks to do I-P-O experiments!
Upload the Firmware for Mind+
Connect Bittle.
Notice the direction of the pins
Configure the Graphical Coding Environment
Paste the Mind+ library’s address https://github.com/PetoiCamp/Petoi_MindPlusLib into the field
Note to MAC users:
After importing the extension library, Please copy the folder (PetoiRobot) extracted from PetoiRobot.zip to /Users/{your The username}/ Documents/mindplus-py/environment/Python3.6.5-64/lib/python3.6/site-packages/.
The version number 3.6.5 May be slightly different
Build The Program and Run It
什么是红外光?
Infrared radiation is an electromagnetic wave in the infrared band between visible light and microwave, with a wavelength range from 780 nanometers to 1 mm. It is invisible light with a lower frequency than red light. It has all the properties of light.
What is Infrared Light?
The light reflected off an object's surface determines the color we see
Use scenario:
Infrared sensors usually utilize the transmission or reflection of infrared light.
The infrared thermometer measures the infrared radiation from the human body to calculate its temperature.
Infrared from the Human Body
The human body emits specific infrared light
Detects infrared light emitted by the human body
photosensitive element
Fresnel lens
When a hot object moves,
it causes a change in the voltage on the sensor
Heat
Detect Motion
Connect the PIR Sensor
After connecting the hardware, we can display the value detected by the sensor on the serial port monitor
We're going to learn a new function that lets Bittle read the value from the digital sensor
Digital Read
Digital Read
If person detected:
the serial monitor prints 1;
Else
prints 0;
\CODE\5.01_FindPeopleAndPrint.mp
Thinking & Analysis
Task 1
Please write code to achieve:
If someone is detected:
Turn on the LED
Else:
Turn off the LED
\CODE\5.02_FindPeopleAndOpenLED.mp
Task 2
Modify the above code so that:
If the sensor detects someone:
Triggers the alarm
Else
Stop playing
\CODE\5.03_FindPeopleAndOpenBuzzer.mp
Task 3
Please write code:
If the sensor detects someone:
Sit
Trigger an alarm
Light the LED
Else:
Lay down
Stop the alarm
Turn off the LED
\CODE\5.04_FindPeopleAndSit.mp
See the tutorial video.
Summary
It‘s great that Bittle can feel
the environment and react
Next time we'll continue to help Bittle perceive the world
woof~
woof~