Skip to content

Instantly share code, notes, and snippets.

@REPTILEHAUS
Created February 25, 2017 14:39
Show Gist options
  • Save REPTILEHAUS/a2259b0e739c18bb015f09478862c686 to your computer and use it in GitHub Desktop.
Save REPTILEHAUS/a2259b0e739c18bb015f09478862c686 to your computer and use it in GitHub Desktop.
<?php
// SPECIFY USB PORT TO USE
$usb_comPort = "COM4";
switch($_POST)
{
case isset($_POST['submitOn']):
exec("ECHO 1 > $usb_comPort"); // Turn On LED 1
break;
case isset($_POST['submitOff']):
exec("ECHO 2 > $usb_comPort "); // Turn Off LED 1
break;
case isset($_POST['submitOn1']):
exec("ECHO 3 > $usb_comPort"); // Turn On LED 2
break;
case isset($_POST['submitOff1']):
exec("ECHO 4 > $usb_comPort"); // Turn Off LED 1
break;
case isset($_POST['submitOn2']):
exec("ECHO 5 > $usb_comPort"); // Turn On LED 3
break;
case isset($_POST['submitOff2']):
exec("ECHO 6 > $usb_comPort"); // Turn Off LED 1
break;
case isset($_POST['submitOn3']):
exec("ECHO 7 > $usb_comPort"); // Turn On LED 4
break;
case isset($_POST['submitOff3']):
exec("ECHO 8 > $usb_comPort"); // Turn Off LED 1
break;
case isset($_POST['allon']):
exec("ECHO 1,3,5,7 > $usb_comPort"); // Turn ON ALL 4 LED Bulbs
break;
case isset($_POST['alloff']):
exec("ECHO 2,4,6,8 > $usb_comPort"); // Turn OFF ALL 4 LED Bulbs
break;
}
?>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600' rel='stylesheet' type='text/css'>
<style type="text/css">
body {
background: #333;
}
h1 {
text-align: center;
font-family: 'Source Sans Pro', sans-serif;
font-size: 6em;
color: #eee;
line-height: 63px;
margin: 46px 0;
}
form.control-panel-frm {
margin: 0 auto;
text-align: center;
}
input.s3d {
clear: both;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 4px 5px rgba(0, 0, 0, .3);
box-shadow: 0 4px 5px rgba(0, 0, 0, .3);
display: inline-block !important;
font: 700 13px/36px 'Arial', Helvetica, Clean, sans-serif;
padding: 10px 47px;
width: 225px;
position: relative;
text-decoration: none;
text-shadow: 0 1px 1px rgba(255, 255, 255, .35);
}
input.switchoff {
background: #eb5a5f;
background: -webkit-gradient(linear, 0 0, 0 0, from(#eb5a5f), to(#e13c41));
background: -moz-linear-gradient(#eb5a5f, #e13c41);
background: linear-gradient(#eb5a5f, #e13c41);
border: 0;
color: rgba(69, 22, 24, 1);
}
input.switchoff:active {
background: #e13c41;
background: -webkit-gradient(linear, 0 0, 0 0, from(#e13c41), to(#eb5a5f));
background: -moz-linear-gradient(#e13c41, #eb5a5f);
background: linear-gradient(#e13c41, #eb5a5f);
}
input.turnOn {
background: #58853e;
background: -webkit-gradient(linear, 0 0, 0 0, from(#00CC00), to(#00FF33));
background: -moz-linear-gradient(#00CC00, #00FF33);
background: linear-gradient(#00CC00, #00FF33);
border: 0;
color: rgba(22, 33, 16, 1);
}
input.turnOn:active {
background: #3c592a;
background: -webkit-gradient(linear, 0 0, 0 0, from(#3c592a), to(#58853e));
background: -moz-linear-gradient(#3c592a, #58853e);
background: linear-gradient(#3c592a, #58853e);
}
</style>
</head>
<body>
<h1>Control Panel</h1>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<input type='submit' name='submitOn' value='Turn LED 1 ON'>
<input type='submit' name='submitOff' value='Turn LED 1 OFF'>
<br><br>
<input type='submit' name='submitOn1' value='Turn LED 2 ON'>
<input type='submit' name='submitOff1' value='Turn LED 2 OFF'>
<br><br>
<input type='submit' name='submitOn2' value='Turn LED 3 ON'>
<input type='submit' name='submitOff2' value='Turn LED 3 OFF'>
<br><br>
<input type='submit' name='submitOn3' value='Turn LED 4 ON'>
<input type='submit' name='submitOff3' value='Turn LED 4 OFF'>
<br><br>
<input type='submit' name='allon' value='Turn ALL LEDs On'>
<input type='submit' name='alloff' value='Turn ALL LEDs Off'>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment