use warnings; use strict; use RPi::WiringPi; my $pi = RPi::WiringPi->new; my $pin = $pi->pin(27); # GPIO pin 27 my $count; while (1){ # check if time >= 0900 here # ...if not, sleep and next my $motion = 0; for (0..10){ if ($pin->read == 1){ $motion = 1; last; } sleep 5; } $count++ if ! $motion; if ($count >= 3){ # 0915 hrs and no movement # send email, sound an alarm etc ... } sleep 300; }