r.addEventListener("click", async () => {
      try {
        const websocketPort = port.value;        
        const localPort = `ws://localhost:${websocketPort}`;  
        // Establish a WebSocket connection to the server
        ws = new WebSocket(localPort);
  
        // Change the LED status to 'on'
        sled.classList.remove("led-off");
        sled.classList.add("led-on");
  
        // Display a success message
        const statusMsg = document.getElementById("status-msg");
      