[TASK] Monitoring a touch sensor

[TASK] Monitoring a touch sensor

Postby admin » Wed Nov 04, 2015 3:41 pm

We will go through an example to print input signal of a touch sensor by using a PHPoC Blue.

Image

Diagram

Image

Source Codes
1. task0.php

Code: Select all

<?php
 
if(_SERVER("REQUEST_METHOD"))
    exit; // avoid php execution via http request
 
include_once 
"/lib/sd_340.php";
 
define
("IN_PIN", 0);
 
echo 
"PHPoC example : P4S-34X / UIO / Catalex Touch Sensor\r\n";
 
uio_setup
(0, IN_PIN, "in");
 
$last_touch 
= 0;
 
while(1)
{
    $touch = uio_in(0, IN_PIN);
 
    if
($touch != $last_touch)
    {
        if($touch)
            echo "touch ON\r\n";
        else
            echo 
"touch OFF\r\n";
 
        $last_touch 
= $touch;
    }
}
 
?>


Please download a PSP (PHPoC Support Package) of libraries and examples from PHPoC, and upload it in the PHPoC Blue.

Image

Video

phpBB [video]
admin
Site Admin
 
Posts: 167
Joined: Mon Jan 20, 2014 4:40 pm

Return to Example

Who is online

Users browsing this forum: No registered users and 1 guest

cron