When a person approaches, turn on the warning light and horn


Hardware components
× 1
× 1
Waring Light and Horn
× 1
Adafruit HC SR501
× 1




Demonstration






Wiring:
  • Stack Relay Smart Expansion Board on PHPoC Blue
  • Connect Light and Horn to Relay 0 of Smart Expansion Board
  • Connect Motion sensor to PHPoC: VCC -> 5V, GND -> GND, OUT -> 11




Schematics

Click image for larger version  Name:	wiring.jpg Views:	0 Size:	64.9 KB ID:	1599





Code

PHP Code:
<?php

include_once "/lib/sd_340.php";
include_once 
"/lib/sd_spc.php";

spc_reset();
spc_sync_baud(115200);
spc_request_dev(1"set 0 output low");

uio_setup(011"in");


while(
1)
{
    
$in_value = (int)uio_in(011);

    if(
$in_value)
        
spc_request_dev(1"set 0 output high");
    else
        
spc_request_dev(1"set 0 output low");
}
?>