Repository navigation
Expand file tree
/
Copy pathled_control.php
More file actions
89 lines (82 loc) · 2.46 KB
/
Copy pathled_control.php
File metadata and controls
89 lines (82 loc) · 2.46 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!-- การสร้างแอปพลิเคชัน App Inventor โดยเชื่อมต่อ กับ ไฟล์ PHP -->
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Control LED with Raspberry Pi using Apache Webserver </title>
</head>
<style>
body {
background-color: rgb(212, 250, 252);
font-family: 'Arial';
}
.green {
background-color: green;
width: 10em;
height: 4em;
font-size: 20px;
}
.black {
background-color: red;
color: #fff;
width: 10em;
height: 4em;
font-size: 20px;
}
</style>
<body>
<center>
<form method="get">
<input class="green" type="submit" value="ON" name="on1">
<input class=" black" type="submit" value="OFF" name="off1">
<br /> <br />
<input class="green" type="submit" value="ON" name="on2">
<input class="black" type="submit" value="OFF" name="off2">
<br /> <br />
<input class="green" type="submit" value="ON" name="on3">
<input class="black" type="submit" value="OFF" name="off3">
<br /> <br />
<input class="green" type="submit" value="ON" name="on4">
<input class="black" type="submit" value="OFF" name="off4">
<br /> <br />
</form>
</center>
<?php
//------------------ หลอด 1 ----------------------------
if(isset($_GET['on1']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 17 op pn dh");
}
else if(isset($_GET['off1']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 17 op pn dl");
}
//------------------ หลอด 2 ----------------------------
if(isset($_GET['on2']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 2 op pn dh");
}
else if(isset($_GET['off2']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 2 op pn dl");
}
//------------------ หลอด 3 ----------------------------
if(isset($_GET['on3']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 23 op pn dh");
}
else if(isset($_GET['off3']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 23 op pn dl");
}
//------------------ หลอด 4 ----------------------------
if(isset($_GET['on4']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 24 op pn dh");
}
else if(isset($_GET['off4']))
{
shell_exec("/usr/bin/sudo raspi-gpio set 24 op pn dl");
}
?>
</body>
</html>