-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpio-php-gpio.php
49 lines (49 loc) · 1.17 KB
/
gpio-php-gpio.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<html>
<head>
<title>GPIO test - php-gpio</title>
<style type="text/css">
<!--
input#submit_button {
font-size: 2.0em;
width: 50%;
height: 100px;
}
-->
</style>
</head>
<body>
<h1>
<?php
require 'lib/vendor/autoload.php';
use PhpGpio\Gpio;
$pin = 4
$gpio = new GPIO();
if (isset($_POST["Initialize_Pin"])) {
echo "Initialize GPIO pin $pin";
$gpio->setup($pin, "out");
}
else if(isset($_POST["LED_ON"])) {
echo "LED ON";
$gpio->output($pin, 1);
}
else if(isset($_POST["LED_OFF"])) {
echo "LED OFF";
$gpio->output($pin, 0);
}
else if(isset($_POST["Finalize_Pin"])) {
echo "Finalize GPIO pin $pin";
$gpio->unexport($pin);
}
else {
echo "Press Initialize_Pin button first";
}
?>
</h1>
<form method="POST" action="">
<input type="submit" value="Initialize_Pin" name="Initialize_Pin" id="submit_button"><br />
<input type="submit" value="LED_ON" name="LED_ON" id="submit_button"><br />
<input type="submit" value="LED_OFF" name="LED_OFF" id="submit_button"><br />
<input type="submit" value="Finalize_Pin" name="Finalize_Pin" id="submit_button">
</form>
</body>
</html>