Spaces:
Runtime error
Runtime error
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Real-Time Data from Arduino</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script> | |
</head> | |
<body> | |
<h1>Real-Time Data from Arduino</h1> | |
<div id="serialData">Waiting for data...</div> | |
<script> | |
// Connect to the WebSocket server | |
const socket = io(); | |
// Listen for the 'response' event from the server | |
socket.on('response', function(data) { | |
// Update the webpage with the new data | |
document.getElementById('serialData').innerText = 'Arduino Data: ' + data.message; | |
}); | |
// Send a test message (optional) | |
socket.emit('message', 'Hello from browser'); | |
</script> | |
</body> | |
</html> | |