Advertisement
rabirajkhadka

Codes_RPiWorkshop-ran

Dec 9th, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.44 KB | None | 0 0
  1. #LED ON
  2. import time, RPi.GPIO as GPIO
  3. GPIO.setmode(GPIO.BOARD)
  4. GPIO.setup(5,GPIO.OUT)
  5. GPIO.setwarnings(False)
  6. GPIO.output(5, True)
  7. time.sleep(1)
  8.  
  9. #LED OFF
  10. import time, RPi.GPIO as GPIO
  11. GPIO.setmode(GPIO.BOARD)
  12. GPIO.setup(5,GPIO.OUT)
  13. GPIO.setwarnings(False)
  14. GPIO.output(5, False)
  15. time.sleep(1)
  16.  
  17. #LED BLINK
  18. import time, RPi.GPIO as GPIO
  19. GPIO.setmode(GPIO.BOARD)
  20. GPIO.setup(5,GPIO.OUT)
  21. GPIO.setwarnings(False)
  22. while True:
  23. GPIO.output(5, False)
  24. time.sleep(1)
  25. GPIO.output(5, True)
  26. time.sleep(1)
  27.  
  28.  
  29.  
  30. <?php
  31.  if (isset($_POST['on']))
  32.  {
  33.  exec("sudo killall python");
  34.  exec("sudo python /var/www/ledon.py");
  35.  }
  36.  else if (isset($_POST['off']))
  37.  {
  38.  exec("sudo killall python");
  39.  exec("sudo python /var/www/ledoff.py");
  40.  }
  41.  else if (isset($_POST['blink']))
  42.  {
  43.  exec("sudo python /var/www/ledblink.py");
  44.  }
  45. ?>
  46.  
  47. <html>
  48. <style type="text/css">
  49. //Button colour is now yellow and size has been changed
  50.  #form{font: bold 30px/30px Georgia, serif;}
  51.  button{background: #512607 ; width:
  52. 200px; height: 100px;border: none;border: 3px solid black;borderradius:20px;}
  53.  #container{margin0px; auto;width:80%;min-width:40%;}
  54. </style>
  55. <body>
  56. <div id="container">
  57.  <form id="form" method="post">
  58.  <center>
  59. <h1>Internet of Things over LAN</h1>
  60. <br> <button name="on"><h1>Led ON</h1></button><br>
  61.  <button name="off"><h1>Led OFF</h1></button><br>
  62. <button name="blink"><h1>Led BLINK</h1></button>
  63.  </form>
  64.  </div>
  65. </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement