This digital input example uses a motion sensor to turn on a LED every time it detects a movement.
The motion sensor detects the movement of people in a certain area and is realized with a PIR (Passive InfraRed). Two separate sensors independently measure the amount of infrared radiation emitted by your body. If the two measurements are different the movement of your body is deduced (Figure 1).
Sets how long the output remains high after detecting motion (from 5 seconds to 5 minutes)
Sets the detection range (from 3 meters to 7 meters)
Set for single (No reset) or repeatable triggers (Auto-reset).
The sensor has 3 PINs (Figure 2):
The sensor will detect motion inside a 110 degree cone with a range of 3 to 7 meters (Figure 3).
The sensor requires nearly a minute to initialize. During this period, it can and often will output false detection signals. Circuit or controller logic needs to take this initialization period into consideration.
Connect the Pir and the led as shown in Figure 4:
Note: the longer LED PIN is the positive.
Write a sketch K to define:
When the automa has 2 states use led as a status variable.
Pir :: D3
gnd :: d8
led :: d7
EndMotion = !Pir
Motion = Pir
start=[gnd=0,led=0]
stop = [led=0]
!led & Motion -> led=1 ##
led & EndMotion -> led=0 ##
or simply load the sketch in the workspace with the command
] load e07_motion_sensor
Initialize the system with the command
] start
the LED is off.
Move in front of the PIR!
< Motion
the LED turns on and the Motion event is sent to the Internet
Do not move in front of the PIR!
< EndMotion
the LED turns off and the EndMotion event is sent to the Internet
Try the following commands now:
] stop
turns off the LED and the PIR is insensitive to movement!
] start
reestablish motion detection
] pause
suspends motion detection.
Do you notice a difference with the stop command?
What is the command to resume motion detection?
In this lesson you learned or repeated: