Topic 3 - External Input Devices Python
Topic 3 - External Input Devices Python
Think
Act
How can we use this for the next activity later on?
Activity: Sensors
Sensor Video Reflection Answers
A conditional loop is a
set of programming Is plate Yes
instructions that is empty?
End
performed at only 1
No
point of the program
repeatedly until a Use spoon to scoop
up rice on plate
condition is satisfied.
Put spoon in
mouth
Download and Save Library File:
Go to:
bit.ly/ZENCFF2023_MB_TEXT_SUPP
Download sw_gpio.py
Download and Save Library File:
Go to: python.microbit.org
Click on Project > Open > Choose
your sw_gpio file.py > Change to
add file
Download and Save Library File:
Write a program to play a melody and turn ON light (micro:bit onboard LED) for
5 seconds when PIR sensor detects a motion and turn OFF light when there is no
motion detected.
Activity 3.1:
STEP ②
Write the program.
Challenge:
How can we make this
into an intruder alarm?
Activity 3.1:
Challenge:
How can we make this into an intruder alarm?
Modify the codes to have text and icons, with a different sound!
Light Sensor
A light sensor can detect
the light value of the
current environment.
Light sensors measure
illuminance.
Activity 3.2:
Start
Write a program to turn ON light
(micro:bit onboard LEDs) for 5
seconds when light sensor detects low Is light sensor No
intensity of light (dim or darkness) value less
than _____ ?
and turn OFF light when the room is
bright enough. Yes
End
STEP ②