Control a box with a physical joystick!

Yesterday I made a breakthrough discovery. Since JavaScript actually has serial communication support on some browsers, and Arduino can send and receive serial, then you can directly interface a webpage with an Arduino! It’s super cool and opens up so many possibilities: this project is just my start at that.

How it works

  1. The Arduino detects joystick movement.
  2. When it does, the Arduino sends a serial message telling which direction. It does this at 9600 bps (baud per second).
  3. The website listens to the serial port via navigator.serial
  4. It breaks down what message was sent
  5. An if statement decides where and how much to move the box on-screen.

How to set it up?

Follow the instructions on the website to connect everything. I’ve only tested this with an UNO R3, so you might have to modify some stuff if using it with a different board.

Link?

https://replit.com/@boston2029/GameController

I would host it too but it’s such a simple little program that you can just fork it and it works on replit.dev.

Overall I think this is extremely cool and opens up potential for a website that sets off an alarm. I mean, think about that. A horror game with this! Yeah. Adapt this however you want if you have an Arduino.

7 Likes

Ideas that use this technology (if you have any):

  • Make my own game controller with a module any developer can use to support their game with it. It’ll have a joystick, buttons, and everything. Even a fan to keep you cool during intense gaming.
2 Likes