-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpio-file.php
48 lines (48 loc) · 1.3 KB
/
gpio-file.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
<html>
<head>
<title>GPIO test - filesystem</title>
<style type="text/css">
<!--
input#submit_button {
font-size: 2.0em;
width: 50%;
height: 100px;
}
-->
</style>
</head>
<body>
<h1>
<?php
$pin = 4;
if (isset($_POST["Initialize_Pin"])) {
echo "Initialize GPIO pin $pin";
file_put_contents('/sys/class/gpio/export','$pin');
usleep(50000);
file_put_contents('/sys/class/gpio/gpio$pin/direction','out');
}
else if(isset($_POST["LED_ON"])) {
echo "LED ON";
file_put_contents('/sys/class/gpio/gpio$pin/value','1');
}
else if(isset($_POST["LED_OFF"])) {
echo "LED OFF";
file_put_contents('/sys/class/gpio/gpio$pin/value','0');
}
else if(isset($_POST["Finalize_Pin"])) {
echo "Finalize GPIO pin $pin";
file_put_contents('/sys/class/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>