WebUSB API
This project turns a device into a stateless machine which can be communicated with from any language in the browser using an API. For example you can change the colours of the LEDs or play a tune.
The initial implementation (and hence demo) uses Python (implemented with Skulpt)
No code is run on the device - code runs in the browser and the device is just controlled with the API (so the device always needs to be connected with a USB cable)
Quickstart
- Buy a suitable device eg Adafruit Circuit Playground Express and plug it into a USB port with a suitable micro-USB cable
- Install Arduino IDE & also the libraries for the Circuit Playground Express and TinyUSB see Using WebUSB with Arduino and TinyUSB
- Go into Boards Manager (Ctrl-Shift-B) and delete all the Circuit Playground Express boards except Adafruit Circuit Playground Express SAMD21 (stops the wrong ones being autoselected)
- Select Adafruit Circuit Playground Express SAMD21 board
- Select Tools -> USB Stack -> TinyUSB
- Download webusb-api.ino from this repository and open in Arduino IDE
- Compile and upload it to your Circuit Playground Express
- Open web-usb.html in Chrome
- Click “Connect” and select Circuit Playground Express from the dialog
- Type in and run a test program eg to play a tune
webusbNote(440,4)
or set all the LEDs to blue webusb("#0000ff")
These steps just need to be done once. After that it’s as simple as plugging the device in, and clicking on the pop-up message from Chrome to open the URL