Running Arduino code in browser – Wasmino #Arduino #WebAssembly

Unknown Reply 8:50 AM

Wasmino is an Arduino core fully compatible with the Arduino IDE. It allows you to compile your Arduino sketch to WebAssembly and run it in a browser, all using the Arduino IDE.

Some caveats:

The Wasmino should be viewed as having an infinitely fast CPU, and operations other than delay and delayMicroseconds do not take any CPU time. Calling time functions micros and millis should reflect this. IO can only happen during sleep, therefore you cannot do

1
while (!digitalRead(2)) {} // this will hang the browser tab

and should do this instead

1
2
3
while (!digitalRead(2)) {
delay(50);
}

Having a infinitely fast CPU also means that interrupts will only happen during delay and delayMicroseconds. It is still good practice to use noInterrupts and interrupts to protect critical sections if you plan to use your code on real hardware.

Other caveats exist such as the lack of BUILTIN_LED macro since Wasmino, being virtual, doesn’t have a built-in LED.

The Wasmino Arduino core is available at https://github.com/wasmino/wasmino-core.

The runtime is also available at https://github.com/wasmino/wasmino-runtime.

More on Yifan Gu’s Blog

Post a Comment

Search

Follow us

Popular Reviews