Control your Arduino-connected servo from anywhere using a Node.js server and VS Code’s port forwarding.
- Real-time servo control via Socket.IO
- Node.js backend connected to Arduino via USB
- Access your server remotely through VS Code port forwarding [Public]
- Simple setup, no extra cloud cost
- Arduino Uno + servo [PWM digital pin ~9 for signals] connected to your laptop via USB
- Node.js installed on your laptop
- VS Code with Port Forwarding enabled
-
Connect Arduino and Upload Servo Code
- The servo script is saved within the [servoscript\servoscript.ino]
- Upload the script onto arduino uno
- Test it through the Serial port with commands ("l","r","c")
-
Install serialport
npm i socket.io serialport
or just do
npm i
-
Start Node.js Server
node server.js
-
Forward the Server Port in VS Code
- Open VS Code
- Use the port forwarding feature
- Forward your local server port (e.g., 3000) to a public port
-
Access Your Server Remotely - Open the forwarded URL in your phone or any remote device to control your servo.
- This setup exposes your server over the internet — do not expose sensitive ports or services.
- Add authentication in your Node.js app to restrict access if you plan to share your URL.
Thats all we need to control the servo from anywhere! Have Fun.. 😜😁