Advertisement
martin2250

LED Webserver

Aug 26th, 2015
6,357
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.   <head>
  4.     <title>LED Controller</title>
  5.     <meta name="viewport" content="width=400px" />
  6.    
  7.     <script src="socket.io/socket.io.js"></script>
  8.     <link rel="stylesheet" href="style.css">
  9.   </head>
  10.   <body>
  11.     <input type="range" id= "inputSlider" min="0" max="255" value="50" step="1" oninput="showValue(this.value)" />
  12.    
  13.     <br><br><span id="outputText">50</span>
  14.    
  15.     <script type="text/javascript">
  16.         var socket = io.connect();
  17.        
  18.         socket.on('led', function (data) {
  19.             document.getElementById("inputSlider").value = data.value;
  20.             document.getElementById("outputText").innerHTML = data.value;
  21.         });
  22.        
  23.         function showValue(newValue)
  24.         {
  25.             document.getElementById("outputText").innerHTML=newValue;
  26.             socket.emit('led', { value: newValue });
  27.         }
  28.     </script>
  29.   </body>
  30. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement