Running Arduino code in browser – Wasmino #Arduino #WebAssembly
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
anddelayMicroseconds
do not take any CPU time. Calling time functionsmicros
andmillis
should reflect this. IO can only happen during sleep, therefore you cannot do
1while (!digitalRead(2)) {} // this will hang the browser tab
and should do this instead
123while (!digitalRead(2)) {
delay(50);
}
Having a infinitely fast CPU also means that interrupts will only happen during
delay
anddelayMicroseconds
. It is still good practice to usenoInterrupts
andinterrupts
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