Created
January 6, 2023 18:53
-
-
Save Ajak58a/80aeaa5d2768f610dd9203fd7617bb38 to your computer and use it in GitHub Desktop.
Index HTML node js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Node.Js LED Control</title> | |
<meta name="viewport" content="width=400px" /> | |
<script src="socket.io/socket.io.js"></script> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
<p>Move Slider to Change Brightness of LED</p> | |
<input type="range" id= "inputSlider" min="0" max="255" value="50" step="1" oninput="showValue(this.value)" /> | |
<br><br> | |
<span id="outputText">50</span> | |
<script type="text/javascript"> | |
var socket = io.connect(); | |
socket.on('led', function (data) { | |
document.getElementById("inputSlider").value = data.value; | |
document.getElementById("outputText").innerHTML = data.value; | |
}); | |
function showValue(newValue) | |
{ | |
document.getElementById("outputText").innerHTML=newValue; | |
socket.emit('led', { value: newValue }); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment