It's the heart- but not the whole body- of the Arduino simulator at https://wokwi.com.
Example Applications Using
- Wokwi Arduino Simulator - Arduino simulator with a choice of hardware that can be wired up dynamically in your browser!
- Wokwi Playgrounds - pre-configured Arduino circuits with notes and goals. A starting point for an online lesson system.
- avr8js-electron playground - a Downloadable Electron Arduino simulator app
- AVR8js-Falstad - combining the Falstad circuit simulator with AVR8js!
- The Engineering Physics Department of Dawson College's Arduino Course - an introduction to Arduino with a focus on robotics
How to Use This Library
This library only implements the AVR CPU core. You have to supply it pre-compiled machine code to run, and implement functional simulations of any external hardware. You will probably also want to add audio/visual representations of external hardware being simulated.
A rough conceptual diagram:
Pre-Compiled machine code --> AVR8js <--> Glue code <--> external hardware functional simulation <--> simulation state display for the user
You may be interested in exploring the wokwi-elements collection of web-components for visual representations of many common hardware components. (Note: these are visual only elements- you will need to add the appropriate functional simulation and glue code.)
Walkthrough Video Tutorial
A step-by-step video tutorial showing how to build a simple Arduino simulator using AVR8js and React:
And a related blog post.
These examples show working examples of using
avr8js in an application. Many of them also demonstrate how to use the
wokwi-elements and include working examples of functional simulations of the components, and how to hook them up to
- Minimal Example
- 6 LEDs
- LED PWM
- Serial Monitor
- NeoPixel Matrix
- Arduino MEGA NeoPixel Matrix
- Simon Game - with pushbuttons and sound
- XMAS LEDs
- Assembly Code
- EEPROM persistence
Note: they are all hosted outside of this repo.
Running the demo project
The demo project allows you to edit Arduino code, compile it, and run it in the simulator. It also simulates 2 LEDs connected to pins 12 and 13 (PB4 and PB5).
To run the demo project, check out this repository, run
npm install and then
Which chips can be simulated?
The library focuses on simulating the ATmega328p, which is the MCU used by the Arduino Uno.
However, the code is built in a modular way, and is highly configurable, making it possible to simulate many chips from the AVR8 family, such as the ATmega2560 and the ATtiny series:
Running the tests
Run the tests once:
Run the tests of the files you modified since last commit (watch mode):
npm run test:watch
For more information, please check the Contributing Guide.
Copyright (C) 2019, 2020, 2021 Uri Shaked. The code is released under the terms of the MIT license.