Sensor
#struct SensorA PIR motion sensor on a pin, and whether it reports motion with a high or a low level.
| Name | Type | Description |
|---|---|---|
pin | int = 0 | The pin the sensor output is wired to. |
active_high | bool = true | True when motion is a high level (most modules), false when it is a low level. |
import hw.board
import hw.pir
func main:
sensor := pir.Open(7)
println pir.Motion(sensor)
board.SimSetPin(7, 1)
println pir.Motion(sensor), pir.WaitMotion(sensor, 10)
board.SimSetPin(7, 0)
println pir.WaitMotion(sensor, 3)
door := pir.OpenInverted(8)
println pir.Motion(door)
board.SimSetPin(8, 0)
println pir.Motion(door)
endfalse true true false false true