p5js Webserial to Arduino
Working example using a Web-Serial Library. There are a few other webserial libraries available, but this appears to be the easiest to implement, as its setup only requires one line in the index.html and one in the .js function setup()
.
--> build and tested with arduino IDE v2.1 and Processing IDE v4.2 (processing Mode: p5.js v1.6)
Things to Note
- Currently, the setup lines break when using the auto-formatting function in Processing, consider using VSCode.
- All functions need to be async functions in order to work.
- keep in mind that only once program can use a Serial port at a time. This means that you can't open the Arduino Serial monitor when connected to web-serial.
- Webserial currently only works in Chrome.
- Sometimes, the browser cache ignores changes to your script.To avoid this, use incognito mode.
Further information
- A helpful introduction to WebSerial - https://developer.chrome.com/articles/serial/
- WebSerial Example by Tom Igoe (ITP/Arduino) - https://github.com/tigoe/html-for-conndev/tree/main/webSerial