Skip to content

Instantly share code, notes, and snippets.

@REPTILEHAUS
Created February 25, 2017 14:37
Show Gist options
  • Save REPTILEHAUS/87d5e08d14e0b15d19f35bacf5e1d4d7 to your computer and use it in GitHub Desktop.
Save REPTILEHAUS/87d5e08d14e0b15d19f35bacf5e1d4d7 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>
</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