Announcement

Collapse
No announcement yet.

Touch Sensor - Monitoring Touch Sensor from Webpage with Image

Collapse
X
Collapse
  •  

  • Touch Sensor - Monitoring Touch Sensor from Webpage with Image


    Tutorial Video



    Hardware

    About Touch Sensor

    Touch sensor is used to detect the touch of finger. The touch sensor used in this example includes three pins:
    • VCC pin.
    • GND pin.
    • Signal pin (outputs digital signal).
    How the touch sensor works:
    • If sensor is touched by finger, value of the sensor's signal pin is HIGH (VCC).
    • Otherwise, value of sensor's signal pin is LOW (0 V).
    How to use touch sensor:
    • By reading value of sensor's signal pin, we can infer state of touch sensor. To read value of sensor's signal pin, we just need to connect the sensor's signal pin to PHPoC device's input pin and use PHPoC code to read the value.
    We can use another kind of touch sensor instead, even if it has different pinout, for example:We can use the source code of this example if its working principle is the same as the touch sensor used in this example.




    Wiring Diagram



    Quick Steps

    Source code of this example is a part of PHPoC Support Packet (PSP). You need to:
    • Download PHPoC Support Package.
    • Upload example\p4s\03.html_image\01.uio_touch_sensor to PHPoC Blue/Black.
    • Configure network parameters (e.g. WiFi SSID, password, IP address ...).
    • Access webpage on PHPoC using Web Browser on your PC or smart phone (See How To).
    If you use PHPoC for the first time, see How To Use PSP.


    Source Code

    Source files includes:
    • index.php: this file contains source code of web page.It is only run in response to request from Web Browser.
    • uio_touch_sensor.jpg: Wring diagram between PHPoC devices and touch sensor. It is displayed on webpage.

    index.php

    [Full Code]
    PHP Code:
    <html>
    <head>
    <title>PHPoC / <?echo system("uname -i")?></title>
    <meta name="viewport" content="width=device-width, initial-scale=0.5">
    <style> body { text-align: center; } </style>
    </head>
    <body>

    <h2>

    UIO / Catalex Touch Sensor<br>

    <img src="uio_touch_sensor.jpg"><br>

    <?php

    include_once "/lib/sd_340.php";

    define("IN_PIN"0);

    uio_setup(0IN_PIN"in");

    $touch uio_in(0IN_PIN);

    if(
    $touch)
     echo 
    "touch ON<br>\r\n";
    else
     echo 
    "touch OFF<br>\r\n";

    ?>

    <br><a href="index.php">reload</a><br>

    </h2>

    </body>
    </html>



    [Explanation]

    Source code of index.php file is composed of HTML, CSS and PHPoC code.

    PHPoC code is interpreted on on PHPoC device.
    • PHP Code:
      <?php
          
          
      include_once "/lib/sd_340.php";
          
          
      define("IN_PIN"0);
          
          
      uio_setup(0IN_PIN"in");
          
          
      $touch uio_in(0IN_PIN);
          
          if(
      $touch)
          echo 
      "touch ON<br>\r\n";
          else
          echo 
      "touch OFF<br>\r\n";
          
          
      ?>
    This code does:
    • Setup IO pin. which connected to the sensor to input mode.
    • Read value of input pin.
    • Print state of touch sensor based on value of input pin to webpage.


    PHPoC code may add/update the content of HTML, CSS or JavaScript code. Once PHPoC code is interpreted in PHPoC, the remaining code is client-side code and it is returned to Web Browser. Web Browser receives this code and interpret it to display the webpage.
    • HTML: describes the structure of Web pages
    • CSS: describes how HTML elements are to be displayed
    For detail explanation, see How to Monitor Sensors/Devices via HTTP Request




    See Also

    Other Resources
    Last edited by support; 12-14-2022, 07:36 AM.
      Posting comments is disabled.

    Categories

    Collapse

    Latest Articles

    Collapse

    • Arduino - RS-485 Expansion Board
      by support
      PES-2607 is an easy-to-use RS422/RS485 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS422 or RS485.
      Especially, Arduino does NOT use UART pins to communicate with RS422/RS485 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS422/RS485 expansion boards (up to 14) without using Arduino UART pins.

      Library and examples for...
      11-13-2018, 02:45 PM
    • Arduino - RS-422 Expansion Board
      by support
      PES-2607 is an easy-to-use RS422/RS485 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS422 or RS485.
      Especially, Arduino does NOT use UART pins to communicate with RS422/RS485 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS422/RS485 expansion boards (up to 14) without using Arduino UART pins.

      Library and examples for...
      11-13-2018, 02:44 PM
    • Arduino - RS-232 Expansion Board
      by support
      PES-2606 is an easy-to-use RS-232 Expansion Board for Arduino Uno and Mega, which allows Arduino to exchange data with serial device via RS-232.
      Especially, Arduino does NOT use UART pins to communicate with RS-232 expansion board. Therefore, users can use Arduino UART pins for other purposes.
      Moreover, A single Arduino Uno/Mega can communicate with multiple RS-232 expansion boards (up to 14) without using Arduino UART pins.

      Library and example for the RS-232 expansion board...
      11-13-2018, 02:43 PM
    • Arduino - Stepper Motor Controller
      by support
      PES-2605 is an easy-to-use stepper motor controller for Arduino Uno and Mega, which uses micro-stepping method to precisely control stepper motor.
      Library and example for the stepper motor controller are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use the step motor controller with an example of PhpocExpansion library for Arduino.


      Hardware Required...
      11-13-2018, 02:41 PM
    • Arduino - DC Motor Controller
      by support
      PES-2604 is an easy-to-use DC motor controller for Arduino Uno and Mega.
      Library and example for the DC motor controller are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use the DC motor controller with an example of PhpocExpansion library for Arduino.


      Hardware Required...
      11-13-2018, 02:40 PM
    • Arduino - Digital Input Board
      by support
      PES-2602 is an easy-to-use 4-port Input Expansion Board for Arduino Uno and Mega, which allows Arduino to monitor state of DC electric device. In addition, it can monitor NPN, PNP and dry contact(relay).
      Library and example for the 4-port input expansion board are part of of PhpocExpansion library for Arduino. The library reference is available here.

      This tutorial shows how to use 4-port input expansion board with an example of PhpocExpansion library for Arduino.

      ...
      11-13-2018, 02:39 PM
    Working...
    X