Skip to content

Instantly share code, notes, and snippets.

@ThePratikSah
Last active November 26, 2018 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThePratikSah/741a22b1f93a2c8f5c425a75ba6bae85 to your computer and use it in GitHub Desktop.
Save ThePratikSah/741a22b1f93a2c8f5c425a75ba6bae85 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Pi Remote Control</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
crossorigin="anonymous">
</head>
<body>
<?php
if(isset($_POST['ON'])){
exec("sudo python lightOn.py");
}
if(isset($_POST['OFF'])){
exec("sudo python lightOff.py");
}
?>
<div class="row">
<div class="col s12 m5">
<div class="card-panel teal">
<blockquote class="white-text">
<h4>Control your lights from here!</h4>
</blockquote>
</div>
</div>
</div>
<div class="row center">
<div class="col s12 m5">
<div class="card-panel">
<!-- button starts here -->
<form method="post">
<button class="waves-effect waves-light btn" name="ON">Turn ON <i class="fas fa-lightbulb"></i></button>
<button class="waves-effect waves-light btn" name="OFF">Turn OFF <i class="far fa-lightbulb"></i></button>
</form>
</div>
</div>
</div>
</body>
</html>
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pinList = [2]
for i in pinList:
GPIO.setwarnings(False)
GPIO.setup(i, GPIO.OUT)
GPIO.output(i, GPIO.HIGH)
def trigger():
for i in pinList:
GPIO.output(i, GPIO.LOW)
break
try:
trigger()
except KeyboardInterrupt:
print("Quit")
GPIO.cleanup()
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
pinList = [2]
for i in pinList:
GPIO.setwarnings(False)
GPIO.setup(i, GPIO.OUT)
GPIO.output(i, GPIO.HIGH)
def trigger():
for i in pinList:
GPIO.output(i, GPIO.HIGH)
break
try:
trigger()
except KeyboardInterrupt:
print("Quit")
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment