Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Sterowanie oświetleniem...
nawasaqi
post
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 28.12.2010

Ostrzeżenie: (0%)
-----


Witam serdecznie Panowie mam problem ze skryptem mianowicie coś mi nie działa jakby ktoś bardziej obeznany mógł to zobaczyć gdzie popełniłem błąd... ;(
Skrypt jest banalnie prosty bo ma ustawić obierać 2 stany wysoki i niski czyli światełka włączone i wyłaczone.
  1. <html>
  2. <head>
  3. <style rel="stylesheet" type="text/css" >
  4. <!--
  5. body{
  6. font-family: Arial, Helvetica, sans-serif;
  7. background: #061539;
  8. }
  9. #caly_blok{
  10. width:1000px;
  11. padding-top: 10px;
  12. margin-top: 25px;
  13. margin-left: auto;
  14. margin-right: auto;
  15. text-align: center;
  16. background: #F0F0F0;
  17. }
  18. #stopka{
  19. width: 1000px;
  20. height: 25px;
  21. padding-left: 10px;
  22. text-align: left;
  23. color: #787878;
  24. margin-top: 40px;
  25. clear: both;
  26. font-size: 12px;
  27. font-weight: bold;
  28. }
  29. .centruj{
  30. padding-left:330px;
  31. padding-right: 330px;
  32. }
  33. .button1{
  34. border-bottom:3px ridge #056405;
  35. border-right:3px ridge #056405;
  36. border-left:1px ridge #056405;
  37. border-top:1px ridge #056405;
  38. border-radius: 20px;
  39. color: #10621E;
  40. font-size: 35px;
  41. background: #CDD7CD;
  42. width: 250px;
  43. height: 150px;
  44. box-shadow: 10px 10px 10px #5AAC56;
  45. vertical-align: middle;
  46. margin: 30px;
  47. }
  48. .button1:hover{
  49. background: #88AF7B;
  50. }
  51. .button2{
  52. border-bottom:3px ridge #8C0E07;
  53. border-right:3px ridge #8C0E07;
  54. border-left:1px ridge #8C0E07;
  55. border-top:1px ridge #8C0E07;
  56. border-radius: 20px;
  57. color: #660500;
  58. font-size: 35px;
  59. background: #DEB6B4;
  60. width: 250px;
  61. height: 150px;
  62. box-shadow: 10px 10px 10px #D46A6A;
  63. vertical-align: middle;
  64. margin: 30px;
  65. }
  66. .button2:hover{
  67. background: #CB827E;
  68. }
  69.  
  70. -->
  71. </style>
  72. </head>
  73.  
  74. <?php
  75.  
  76. function sterujPin($zmiana, $stan, &$doButtona, &$doNapisu, &$nowyStan)
  77. {
  78. if($stan==0)
  79. {
  80. $doButtona = "button1";
  81. $doNapisu = "Włączone";
  82. $nowyStan = 1;
  83. if ($zmiana == 1)
  84. {
  85. shell_exec('gpio mode 2 out');
  86. shell_exec('gpio write 2 0');
  87. }
  88. }else
  89. {
  90. $doButtona = "button2";
  91. $doNapisu = "Wyłączone";
  92. $nowyStan = 0;
  93. if ($zmiana == 1)
  94. {
  95. shell_exec('gpio mode 2 in');
  96. shell_exec('gpio write 2 1');
  97. }
  98. }
  99.  
  100. }
  101. ?>
  102. <body>
  103. <?php
  104. $stanPinu2 = shell_exec('gpio read 2');
  105. $czyZmiana = 0;
  106.  
  107. if (isset($_POST['stan']))
  108. {
  109. $czyZmiana = 1;
  110. sterujPin($czyZmiana, $_POST['stan'], $jakiButon, $jakiNapis, $doStanu);
  111. }else
  112. {
  113. sterujPin($czyZmiana, $stanPinu2, $jakiButon, $jakiNapis, $doStanu);
  114. }
  115. ?>
  116.  
  117. <div id="caly_blok">
  118. <h1>Włącznik światełek</h1>
  119. <p>
  120. <?php
  121. echo date('m.d.Y H:i:s');
  122. //echo $stanPinu2;
  123. ?>
  124. </p>
  125. <p>
  126. <form action="index.php" method="post" class="centruj">
  127. <fieldset>
  128. <legend> Oświetlenie dachu </legend>
  129. <?php
  130. echo '<input type="submit" value="'.$jakiNapis.'" class="'.$jakiButon.'">
  131. <input name="stan" value="'.$doStanu.'" type="hidden">';
  132. ?>
  133. </fieldset>
  134. </form>
  135. </p>
  136. <div id ="stopka">
  137. Sterowanie oświetleniem na zewnątrz.
  138. </div>
  139. </div>
  140. </body>
  141. </html>



Z góry dziękuję za pomoc...

Ten post edytował nawasaqi 18.12.2016, 16:34:10
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.09.2025 - 13:43