Advertisement
mem1889

Untitled

Feb 6th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Documento sin t&iacute;tulo</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <style type="text/css">
  8. <!--
  9. .Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif}
  10. .Estilo2 {font-size: 60px}
  11. .Estilo3 {font-size: 50px}
  12. .Estilo4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 50px; }
  13. -->
  14. </style>
  15. </head>
  16.  
  17. <body>
  18. <div align="center">
  19. <h1 class="Estilo1 Estilo2">Contol de Riego </h1>
  20. <table width="688" border="2" cellpadding="3" cellspacing="2" bgcolor="#0099CC">
  21. <tr>
  22. <td width="320" class="Estilo4">Riego Exterior</td>
  23. <td width="171" class="Estilo4"><div align="center"><a href="<?=$_SERVER['PHP_SELF'] . "?action=on" ?>">ON</a></div></td>
  24. <td width="161" class="Estilo4"><div align="center"><a href="<?=$_SERVER['PHP_SELF'] . "?action=off" ?>">OFF</a></div></td>
  25. </tr>
  26. </table>
  27. <p class="Estilo1"><span class="Estilo3"><a href="control.php">Regresar</a></span></p>
  28. <p class="Estilo1">&nbsp;</p>
  29. </div>
  30. </body>
  31. </html>
  32.  
  33. <?php
  34.  
  35.  
  36.  
  37.  
  38. if (isset($_GET['action'])) {
  39. //Action required
  40.  
  41. //Load the serial port class
  42. require("php_serial.class.php");
  43.  
  44. //Initialize the class
  45. $serial = new phpSerial();
  46.  
  47. //Specify the serial port to use... in this case COM1
  48. $serial->deviceSet("/dev/ttyACM0"); //SET THIS TO WHATEVER YOUR SERIAL DEVICE HAPPENS TO BE, YOU CAN FIND THIS UNDER THE ARDUINO SOFTWARE'S MENU
  49.  
  50. //Set the serial port parameters. The documentation says 9600 8-N-1, so
  51. $serial->confBaudRate(9600); //Baud rate: 9600
  52. // $serial->confParity("none"); //Parity (this is the "N" in "8-N-1") ******THIS PART OF THE CODE WAS NOT NEEDED
  53. // $serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1") ******THIS PART OF THE CODE WAS NOT NEEDED
  54. // $serial->confStopBits(1); //Stop bits (this is the "1" in "8-N-1") ******THIS PART OF THE CODE WAS NOT NEEDED
  55. //$serial->confFlowControl("none"); //******THIS PART OF THE CODE WAS NOT NEEDED
  56.  
  57.  
  58. //Now we "open" the serial port so we can write to it
  59. $serial->deviceOpen();
  60.  
  61. //Issue the appropriate command according to the Arduino source code 0=Green On, 1=Green Off, 2=Red On, 3=Red Off.
  62. if ($_GET['action'] == "on") {
  63. //to turn the GREEN LED ON, we issue the command
  64. $serial->sendMessage("z\r");
  65.  
  66. } else if ($_GET['action'] == "off") {
  67. //to turn the GREEN LED OFF, we issue this command
  68. $serial->sendMessage("x\r");
  69. }
  70.  
  71.  
  72. //We're done, so close the serial port again
  73. $serial->deviceClose();
  74.  
  75. }
  76.  
  77.  
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement