Tutorial Video
Hardware
About Built-in LED
There are some LEDs are built-in on PHPoC board. This helps user quickly get started without wiring anything. These LED were already connected to IO pin of PHPoC device.
How to control built-in LED:
- These LEDs are turned ON by setting IO pin of PHPoC device to LOW (0 V).
- These LEDs are turned OFF by setting IO pin of PHPoC device to HIGH (3.3 V).
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\01.php_task\01.uio_ob_led to PHPoC Blue/Black.
- Click "Run" button on PHPoC Debugger.
Source Code
Source files includes:
- init.php: this file is run when PHPoC system is powered or reset. It is used to specify which file is run is system loop.
- task0.php: this file is run in system loop of PHPoC devices.
init.php
This file is run when PHPoC system is powered or reset. It is used to specify that task0.php is run is system loop.
PHP Code:
<?php
system("php task0.php");
?>
task0.php
[Full Code]
PHP Code:
<?php
if(_SERVER("REQUEST_METHOD"))
exit; // avoid php execution via http request
include_once "/lib/sd_340.php";
echo "PHPoC example : P4S-34X / UIO / blink on-board LED\r\n";
uio_setup(0, 30, "out high");
uio_setup(0, 31, "out high");
while(1)
{
uio_out(0, 30, LOW);
uio_out(0, 31, HIGH);
usleep(250000);
uio_out(0, 30, HIGH);
uio_out(0, 31, LOW);
usleep(250000);
}
?>
[Explanation]
Source code of this file does:
- Setup IO pin to output mode and initialize IO pin state to HIGH (LED is off).
- Tongle output pin between LOW and HIGH to blink on-board LED.
See Also
- LED - Controlling LED from Webpage using Hypertext.
- LED - Controlling LED from Webpage with Image.
- LED - Controlling Buzzer via WebSocket.
Other Resources