10 |
11 |
12 |
13 | >
14 | );
15 | }
16 |
--------------------------------------------------------------------------------
/src/theme/NotFound/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import {translate} from '@docusaurus/Translate';
3 | import {PageMetadata} from '@docusaurus/theme-common';
4 | import Layout from '@theme/Layout';
5 | import NotFoundContent from '@theme/NotFound/Content';
6 | export default function Index() {
7 | const title = translate({
8 | id: 'theme.NotFound.title',
9 | message: 'Page Not Found',
10 | });
11 | return (
12 | <>
13 |
14 |
15 |
16 |
17 | >
18 | );
19 | }
20 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-arduino-nano.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-arduino-nano Reference
3 | sidebar_label: wokwi-arduino-nano
4 | ---
5 |
6 | The Arduino Nano is very similar to the [Arduino Uno](wokwi-arduino-uno), but in a smaller form factor. It carries the same ATmega328p chip, which has 32K bytes of Flash program memory, 2k bytes of SRAM and 1K bytes of EEPROM.
7 |
8 |
9 |
10 | For more information, see the [wokwi-arduino-uno reference](wokwi-arduino-uno).
11 |
12 | ## Differences from the Arduino Uno
13 |
14 | The Arduino Nano includes two extra analog pins: A6 and A7. These pins can only be used for Analog input. They can't be used as digital GPIO pins.
15 |
--------------------------------------------------------------------------------
/i18n/en/docusaurus-plugin-content-docs/current.json:
--------------------------------------------------------------------------------
1 | {
2 | "version.label": {
3 | "message": "Next",
4 | "description": "The label for version current"
5 | },
6 | "sidebar.main.category.Getting Started": {
7 | "message": "Getting Started",
8 | "description": "The label for category Getting Started in sidebar main"
9 | },
10 | "sidebar.main.category.Guides": {
11 | "message": "Guides",
12 | "description": "The label for category Guides in sidebar main"
13 | },
14 | "sidebar.main.category.Diagram Reference": {
15 | "message": "Diagram Reference",
16 | "description": "The label for category Diagram Reference in sidebar main"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | branches:
9 | - main
10 |
11 | jobs:
12 | build:
13 | runs-on: ubuntu-latest
14 |
15 | strategy:
16 | matrix:
17 | node-version: [22]
18 |
19 | steps:
20 | - name: Checkout code
21 | uses: actions/checkout@v4
22 |
23 | - name: Use Node.js ${{ matrix.node-version }}
24 | uses: actions/setup-node@v4
25 | with:
26 | node-version: ${{ matrix.node-version }}
27 | cache: 'npm'
28 |
29 | - name: Install dependencies
30 | run: npm ci
31 |
32 | - name: Build project
33 | run: npm run build
34 |
--------------------------------------------------------------------------------
/docs/parts/board-grove-oled-sh1107.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: board-grove-oled-sh1107 Reference
3 | sidebar_label: board-grove-oled-sh1107
4 | ---
5 |
6 | Monochrome display with 128*128 resolution
7 |
8 | 
9 |
10 | ## Pin names
11 |
12 | | # | Name | Description |
13 | | --- | ---- | --------------- |
14 | | 1 | SCL | I2C Clock |
15 | | 2 | SDA | I2C Data |
16 | | 3 | VCC | Power |
17 | | 4 | GND | Ground |
18 |
19 | \* Only the I2C interface is supported. The SPI interface is not simulated.
20 |
21 | ## Simulator examples
22 |
23 | - [SH1107_OLED_Clock](https://wokwi.com/projects/398405932489759745)
24 |
--------------------------------------------------------------------------------
/scripts/thumb-urls.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs');
2 | const glob = require('glob');
3 | const path = require('path');
4 |
5 | const buildDir = path.join(__dirname, '../build');
6 | const files = glob.sync(path.join(buildDir, '**/*.html'));
7 |
8 | for (const file of files) {
9 | const urlPathname = path
10 | .relative(buildDir, file)
11 | .split(path.sep)
12 | .join('/')
13 | .replace(/\/index.html$/, '');
14 | if (urlPathname.endsWith('/search')) {
15 | continue;
16 | }
17 | const html = fs.readFileSync(file, { encoding: 'utf-8' });
18 | fs.writeFileSync(
19 | file,
20 | html.replace(
21 | /https:\/\/docs.wokwi.com(\/[^/]+)?\/img\/wokwi-book\.jpg/g,
22 | `https://thumbs.wokwi.com/docs/${urlPathname}/thumbnail.png`,
23 | ),
24 | );
25 | }
26 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-74hc165.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-74hc595.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-nlsf595.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/docs/parts/board-franzininho-wifi.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: board-franzininho-wifi Reference
3 | sidebar_label: board-franzininho-wifi
4 | ---
5 |
6 | Open source ESP32-S2 development board created in Brazil. See the [ESP32 Guide](../guides/esp32) for more information.
7 |
8 | 
9 |
10 | ## Board hardware
11 |
12 | The board includes three built-in LEDs:
13 |
14 | - Green power LED
15 | - Orange LED connected to pin 33
16 | - Blue LED connected to pin 21
17 |
18 | ## Simulator examples
19 |
20 | - [Franzininho WiFi LCD Clock (NTP) client](https://wokwi.com/projects/323796775459619410)
21 | - [Servo motor control](https://wokwi.com/projects/327061759288410708)
22 | - [LED RGB Mixer (using 3 potentiometers)](https://wokwi.com/projects/324682033130373716)
23 | - [CircuitPython blink example](https://wokwi.com/projects/313606939786347074)
24 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-nokia-5110-screen.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-nokia-5110-screen Reference
3 | sidebar_label: wokwi-nokia-5110-screen
4 | ---
5 |
6 | The Nokia 5110 is a basic graphic LCD screen for lots of applications.
7 |
8 | The monochrome display has an 84 x 48 pixel resolution.
9 |
10 | 
11 |
12 | ## Pin names
13 |
14 | | Name | Description |
15 | | ---- | ------------------- |
16 | | RST | Reset pin |
17 | | CE | Chip enable |
18 | | DC | Data/Command select |
19 | | DIN | Serial data input |
20 | | CLK | Serial clock input |
21 | | VCC | Supply voltage |
22 | | BL | Backlight control |
23 | | GND | Ground |
24 |
25 |
26 | ## Simulator examples
27 | The example below uses the Adafruit PCD8544 library to control the display. The library provides a simple interface for drawing text, shapes and bitmaps on the screen:
28 |
29 | - [Nokia 5110 example: Hello World](https://wokwi.com/projects/422590948073922561)
30 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-rgb-led.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-rgb-led Reference
3 | sidebar_label: wokwi-rgb-led
4 | ---
5 |
6 | 5mm Red, Green and Blue (RGB) LED.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ------------ |
14 | | R | Red LED |
15 | | G | Green LED |
16 | | B | Blue LED |
17 | | COM | Common pin\* |
18 |
19 | \* By default, the common pin is the anode (positive). You can change it by setting the "common" attribute to "cathode".
20 |
21 | ## Attributes
22 |
23 | | Name | Description | Default value |
24 | | ------ | ----------------------------------------- | ------------- |
25 | | common | The common pin type: "cathode" or "anode" | "anode" |
26 |
27 | ## Simulator examples
28 |
29 | - [RGB LED with 3 linear sliders - common cathode](https://wokwi.com/projects/306455554559050306)
30 | - [RGB LED with 3 linear sliders - common anode](https://wokwi.com/projects/435392523281372161)
31 | - [Soft pulsating RGB LED](https://wokwi.com/projects/306461175146611264)
32 |
--------------------------------------------------------------------------------
/docs/vscode/offline-mode.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Running Wokwi Offline
3 | sidebar_label: Offline Mode
4 | description: Running the simulation offline or in restricted network environments.
5 | keywords: [ internet, network, offline]
6 | ---
7 |
8 | Wokwi for VS Code requires an internet connection to run. If you need to use Wokwi for VS Code in an environment without internet access, you can subscribe to the [Pro plan](https://wokwi.com/pricing).
9 |
10 | When running in offline mode, the title of the simulator tab will be "Wokwi Simulator (Offline)", and the simulator will display the date when the simulation engine was last updated:
11 |
12 | 
13 |
14 | To update the simulator engine, go online and start the simulator. The simulator will automatically update the engine to the latest version, and will use it the next time you run the simulator in offline mode.
15 |
16 | ## Offline installation
17 |
18 | If you need to install Wokwi for VS Code on a machine that does not have internet access, we can prepare a custom installation package for you. Please contact us to get a quote.
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2021-2024 CodeMagic LTD
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # wokwi-docs
2 |
3 | View online: https://docs.wokwi.com
4 |
5 | ## Online Development
6 |
7 | You can open a development environment in your browser, without having to install anything on your computer. The development environment lets you quickly preview your changes, and even commit them to GitHub and create a pull request.
8 |
9 | * [Open online dev environment on StackBlitz](https://stackblitz.io/github/wokwi/wokwi-docs)
10 | * [Open online dev environment on Gitpod](https://gitpod.io/#https://github.com/wokwi/wokwi-docs) - requires a GitHub login
11 |
12 | ## Local Development
13 |
14 | You'll need [node.js](https://nodejs.org/) and npm.
15 | Clone this repo to your computer, then install the dependencies:
16 |
17 | ```console
18 | npm install
19 | ```
20 |
21 | Start the local development server:
22 |
23 | ```console
24 | npm start
25 | ```
26 |
27 | This will also open up a browser window with the docs site. Most changes are reflected live without having to restart the server.
28 |
29 | ## License
30 |
31 | This work is licensed under a [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
32 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-7segment-diagram.svg:
--------------------------------------------------------------------------------
1 |
17 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-dip-switch-8.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-dip-switch-8 Reference
3 | sidebar_label: wokwi-dip-switch-8
4 | ---
5 |
6 | Set of 8 electrical switches in a single package
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | -------------------------- |
14 | | 1a | First contact of switch 1 |
15 | | 1b | Second contact of switch 1 |
16 | | 2a | First contact of switch 2 |
17 | | 2b | Second contact of switch 2 |
18 | | … | … |
19 | | 8a | First contact of switch 8 |
20 | | 8b | Second contact of switch 8 |
21 |
22 | ## Keyboard operation
23 |
24 | You can use the keyboard to toggle the swithches while the simulation is running. Click on the DIP switch to select it, then toggle the switches by pressing the keys "1" to "8".
25 |
26 | Firefox users: if the keyboard shortcuts don't work for you, please make sure that the "Search for text when you start typing" setting is disabled.
27 |
28 | ## Simulator examples
29 |
30 | - [DIP Switch + LED Bar example](https://wokwi.com/projects/314167394611233344)
31 | - [Arduino PIND register example](https://wokwi.com/projects/314168546236039745)
32 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-7segment-digits.svg:
--------------------------------------------------------------------------------
1 |
14 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-lcd2004.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-lcd2004 Reference
3 | sidebar_label: wokwi-lcd2004
4 | ---
5 |
6 | An LCD display with 4 lines, 20 characters per line.
7 |
8 |
9 |
10 | This part has the same pins and attributes as the wokwi-lcd1602.
11 |
12 | For **complete information and code examples**, please see the [wokwi-lcd1602 reference](wokwi-lcd1602).
13 |
14 | ### Examples
15 |
16 | | Result | Attrs |
17 | | --------------------------------------------------------------------- | -------------------------------------------- |
18 | | | `{ }` |
19 | | | `{ "pins": "i2c" }` |
20 | | | `{ "background": "blue", "color": "white" }` |
21 |
22 | ## Simulator examples
23 |
24 | - [LCD2004 Tiny Pacman on Wokwi](https://wokwi.com/projects/294590769009787402)
25 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-ir-receiver.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ir-receiver Reference
3 | sidebar_label: wokwi-ir-receiver
4 | ---
5 |
6 | 38KHz infrared receiver
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ---------------- |
14 | | GND | Ground |
15 | | VCC | Positive voltage |
16 | | DAT | Digital output |
17 |
18 | ## Using the receiver
19 |
20 | The receiver can be used in two ways:
21 |
22 | 1. Use the [IR Remote](wokwi-ir-remote) to send infrared commands.
23 | 2. Click on the receiver (while the simulation is running) to send arbitrary [NEC-encoded IR signals](https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051#NEC_Protocol). The user interface lets you specify both the address and the command fields on the NEC message.
24 |
25 | To read the commands from your Arduino Code, you can use the [IRRemote](https://github.com/Arduino-IRremote/Arduino-IRremote) or [IRMP](https://github.com/ukw100/IRMP) libraries.
26 |
27 | ## Simulator examples
28 |
29 | - [IRRemote + LCD Display](https://wokwi.com/projects/298934082074575369)
30 | - [IRRemote + LCD Display with updated IRRemote API](https://wokwi.com/projects/408236279940409345)
31 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-attiny85.svg:
--------------------------------------------------------------------------------
1 |
20 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-ssd1306.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ssd1306 Reference
3 | sidebar_label: wokwi-ssd1306
4 | ---
5 |
6 | Monochrome 128x64 OLED display with I2C interface
7 |
8 |
9 |
10 | Note: this part has been deprecated. Please use [board-ssd1306](./board-ssd1306) instead.
11 |
12 | ## Pin names
13 |
14 | | Name | Description | Arduino Uno pin |
15 | | ----------- | --------------------- | --------------- |
16 | | DATA | I2C data line (SDA) | A4 |
17 | | CLK | I2C clock line (SCL) | A5 |
18 | | DC, RST, CS | Unused\* | - |
19 | | 3V3 | 3.3V regulated output | - |
20 | | GND | Ground | GND |
21 | | VIN | Supply voltage | 5V |
22 |
23 | \* DC, RST and CS are for SPI mode. The SSD1306 simulation only supports I2C mode, so these pins are not functional.
24 |
25 | The default I2C address of the SSD1306 module is 0x3c (60).
26 |
27 | ## Attributes
28 |
29 | | Name | Description | Default value |
30 | | ---------- | -------------------------- | ------------- |
31 | | i2cAddress | I2C address of the display | "0x3c" |
32 |
33 | ## Simulator examples
34 |
35 | See [board-ssd1306](board-ssd1306#simulator-examples).
36 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "wokwi-docs",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "docusaurus": "docusaurus",
7 | "start": "docusaurus start",
8 | "build": "docusaurus build && node scripts/thumb-urls.js",
9 | "swizzle": "docusaurus swizzle",
10 | "deploy": "docusaurus deploy",
11 | "serve": "docusaurus serve",
12 | "clear": "docusaurus clear"
13 | },
14 | "dependencies": {
15 | "@algolia/client-search": "^4.22.0",
16 | "@docusaurus/core": "^3.6.1",
17 | "@docusaurus/preset-classic": "^3.6.1",
18 | "@mdx-js/react": "^3.0.0",
19 | "clsx": "^1.1.1",
20 | "glob": "^11.0.3",
21 | "react": "^18.2.0",
22 | "react-dom": "^18.2.0"
23 | },
24 | "devDependencies": {
25 | "@types/react": "^18.2.47",
26 | "husky": "^5.1.1",
27 | "prettier": "^2.2.1",
28 | "pretty-quick": "^3.1.0"
29 | },
30 | "engines": {
31 | "node": ">=18.0"
32 | },
33 | "husky": {
34 | "hooks": {
35 | "pre-commit": "pretty-quick --staged"
36 | }
37 | },
38 | "browserslist": {
39 | "production": [
40 | ">0.5%",
41 | "not dead",
42 | "not op_mini all"
43 | ],
44 | "development": [
45 | "last 1 chrome version",
46 | "last 1 firefox version",
47 | "last 1 safari version"
48 | ]
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/docs/wokwi-ci/cli-installation.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Wokwi CLI Installation
3 | sidebar_label: CLI Installation
4 | description: Install the CLI to run and automate Wokwi simulations from your terminal.
5 | keywords: [CLI, terminal, CI, Powershell, wokwi-cli]
6 | ---
7 |
8 | The CLI allows you to run Wokwi simulations from your terminal, and integrate them with your CI system. We recommend using the [Wokwi for VS Code](../vscode/getting-started) extension for local development, and the CLI for running your tests on CI.
9 |
10 | Both the CLI and the VS Code extension use the same project configuration files ([wokwi.toml](../vscode/project-config) and [diagram.json](../diagram-format)), so you can use the VS Code extension to create and test your project, and then use the CLI to run it on CI.
11 |
12 | To install the Wokwi CLI, run the following command:
13 |
14 | ```bash
15 | curl -L https://wokwi.com/ci/install.sh | sh
16 | ```
17 |
18 | On Windows, you can use the following command in PowerShell:
19 |
20 | ```powershell
21 | iwr https://wokwi.com/ci/install.ps1 -useb | iex
22 | ```
23 |
24 | Alternatively, you can download the CLI directly from the [GitHub Releases page](https://github.com/wokwi/wokwi-cli/releases/latest). Rename the file to `wokwi-cli` (or `wokwi-cli.exe` on Windows), make it executable (`chmod +x wokwi-cli` on Linux/Mac), and move it to a directory in your PATH (e.g. `/usr/local/bin` on Linux/Mac).
25 |
--------------------------------------------------------------------------------
/docs/chips-api/framebuffer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Framebuffer API
3 | sidebar_label: Framebuffer API
4 | ---
5 |
6 | # Framebuffer API
7 |
8 | Use the framebuffer API to implement displays (LCD, OLED, e-paper, etc.). The display size is defined in the `.chip.json` file. The framebuffer uses 32 bits per pixel. The pixels are stored in the RGBA format. The total size of the buffer is `pixel_width * pixel_height * 4` bytes.
9 |
10 | ### buffer_t framebuffer_init(uint32_t *pixel_width, uint32_t *pixel_height)
11 |
12 | Returns the framebuffer for the current chip, and the pixel dimensions (width/height) of the frame buffer.
13 |
14 | :::warning
15 |
16 | Note: `framebuffer_init` can only be called from `chip_init()`. Do not call it at a later time.
17 |
18 | :::
19 |
20 | ### void buffer_write(buffer_t buffer, uint32_t offset, void \*data, uint32_t data_len)
21 |
22 | Copies `data_len` bytes from `data` into the frame buffer, at the given `offset`.
23 |
24 | ### void buffer_read(buffer_t buffer, uint32_t offset, void \*data, uint32_t data_len)
25 |
26 | Copies `data_len` bytes at the given `offset` of the frame buffer into `data`.
27 |
28 | ## Simulator examples
29 |
30 | - [Basic Framebuffer Chip Example](https://wokwi.com/projects/330503863007183442)
31 | - [SSD1306 I2C OLED Display](https://wokwi.com/projects/371050937178768385)
32 | - [IL9163 128x128 Color LCD Display Driver](https://wokwi.com/projects/333332561949360723)
33 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-resistor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-resistor Reference
3 | sidebar_label: wokwi-resistor
4 | ---
5 |
6 | A resistor.
7 |
8 |
9 |
10 | :::warning
11 | Wokwi only has a very basic analog circuit simulation. You won't be able to use resistors together with
12 | analog components (e.g. potentiometer or NTC temperature sensor). You can still use the resistors as external
13 | pull-up/pull-down resistors.
14 | :::
15 |
16 | ## Pin names
17 |
18 | | Pin | Description |
19 | | --- | ----------- |
20 | | 1 | First pin |
21 | | 2 | Second pin |
22 |
23 | ## Attributes
24 |
25 | | Name | Description | Default value |
26 | | ----- | ------------------- | ------------- |
27 | | value | Resistance, in ohms | "1000" |
28 |
29 | ### Examples
30 |
31 | | Result | Attrs |
32 | | ----------------------------------- | ------------------------- |
33 | | | `{ "value": "1" }` |
34 | | | `{ "value": "220" }` |
35 | | | `{ "value": "10000000" }` |
36 |
37 | Check out the [resistor showcase by Koepel](https://wokwi.com/projects/300936732038136328) for more examples.
38 |
39 | ## Simulator examples
40 |
41 | - [External pull-down resistor](https://wokwi.com/projects/302214836102627848) - How to use a resistor as a pull-down for a button
42 |
--------------------------------------------------------------------------------
/docs/vscode/diagram-editor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Diagram Editor in VS Code
3 | sidebar_label: Diagram Editor
4 | description: Use the visual diagram editor in Wokwi for VS Code to open and edit diagrams, and run the simulation.
5 | keywords: [VS Code, diagram editor, visual editor, diagram.json, simulation]
6 | ---
7 |
8 | # Diagram Editor in VS Code
9 |
10 | The visual diagram editor in Wokwi for VS Code allows you to edit the diagram of your simulation project. It is available in the [Hobby+ and Pro plans](https://wokwi.com/pricing).
11 |
12 | ## Opening the diagram editor
13 |
14 | To open the diagram editor, click on a diagram.json file in the Explorer view. The diagram will open in a new tab. The diagram editor also works for files matching the `diagram.*.json` pattern, such as `diagram.esp32.json`. This is useful if you have multiple target boards in your project, and want to maintain a diagram for each target board.
15 |
16 | If you are using the Community or the Hobby plan, you will be able to view the diagram, but not edit it in the diagram editor. You can still edit the diagram.json file in the text editor.
17 |
18 | ## Editing the diagram as text
19 |
20 | Some advanced features are only available if you modify the diagram in the text editor. You can open the text editor by right clicking on the diagram.json tab, selecting "Reopen Editor With..." and then selecting "Text Editor".
21 |
22 | ## Running the simulation
23 |
24 | You can run the simulation by pressing the green play button in the top left corner of the editor. Wokwi will open a new tab and start the simulation.
25 |
--------------------------------------------------------------------------------
/i18n/en/docusaurus-theme-classic/footer.json:
--------------------------------------------------------------------------------
1 | {
2 | "link.title.Docs": {
3 | "message": "Docs",
4 | "description": "The title of the footer links column with title=Docs in the footer"
5 | },
6 | "link.title.Community": {
7 | "message": "Community",
8 | "description": "The title of the footer links column with title=Community in the footer"
9 | },
10 | "link.title.More": {
11 | "message": "More",
12 | "description": "The title of the footer links column with title=More in the footer"
13 | },
14 | "link.item.label.Welcome": {
15 | "message": "Welcome",
16 | "description": "The label of footer link with label=Welcome linking to /"
17 | },
18 | "link.item.label.diagram.json": {
19 | "message": "diagram.json",
20 | "description": "The label of footer link with label=diagram.json linking to /diagram-format"
21 | },
22 | "link.item.label.Discord": {
23 | "message": "Discord",
24 | "description": "The label of footer link with label=Discord linking to https://wokwi.com/discord"
25 | },
26 | "link.item.label.Twitter": {
27 | "message": "Twitter",
28 | "description": "The label of footer link with label=Twitter linking to https://twitter.com/WokwiMakes"
29 | },
30 | "link.item.label.Blog": {
31 | "message": "Blog",
32 | "description": "The label of footer link with label=Blog linking to https://blog.wokwi.com"
33 | },
34 | "link.item.label.GitHub": {
35 | "message": "GitHub",
36 | "description": "The label of footer link with label=GitHub linking to https://github.com/wokwi/wokwi-docs"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-max7219-matrix-chain-4.svg:
--------------------------------------------------------------------------------
1 |
34 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-relay-module.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Relay Module Reference
3 | sidebar_label: wokwi-relay-module
4 | ---
5 |
6 | Electrically operated switch
7 |
8 | 
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ------------------------------------------- |
14 | | VCC | Supply voltage |
15 | | GND | Ground |
16 | | IN | Control signal (e.g. from micro-controller) |
17 | | NC | Normally closed |
18 | | COM | Common pin |
19 | | NO | Normally open |
20 |
21 | ## Attributes
22 |
23 | | Name | Description | Default value |
24 | | ---------- | ----------------------------------------- | ------------- |
25 | | transistor | "npn" (active-high) or "pnp" (active-low) | "npn" |
26 |
27 | ## Operation
28 |
29 | The relay is an electronic switch.
30 |
31 | When the `IN` pin is high / disconnected, `COM` is connected to `NC` (NC means normally closed).
32 |
33 | When the `IN` pin is low, `COM` is connected to `NO` (NO means normally open).
34 |
35 | Setting the "transistor" attribute to "pnp" inverts the logic: when `IN` is high, `COM` is connected to `NO`, and when `IN` is low / disconnected, `COM` is connected to `NC`.
36 |
37 | ## Simulator Examples
38 |
39 | - [One relay module controlling two LEDs](https://wokwi.com/projects/347308007359513172)
40 | - [Arduino Uno controlling four relay modules](https://wokwi.com/projects/398166790321189889)
41 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-tm1637-7segment.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-tm1637-7segment Reference
3 | sidebar_label: wokwi-tm1637-7segment
4 | ---
5 |
6 | Seven segment LED display module with TM1637 4-wire interface
7 |
8 | 
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | -------------- |
14 | | CLK | Clock input |
15 | | DIO | Data input \* |
16 | | VCC | Supply voltage |
17 | | GND | Ground |
18 |
19 | \* The DIO pin is also used for acknowledging the data received from the microcontroller, by pulling it down at a specific clock cycle.
20 |
21 | ## Attributes
22 |
23 | | Name | Description | Default value |
24 | | ----- | ----------------------------- | ------------- |
25 | | color | The color of the segment LEDs | "red" |
26 |
27 | ## Using the 7-segment display
28 |
29 | This variant of the seven segment display uses the TM1637 chip. You'll only need 2 microcontroller pins to communicate with it.
30 |
31 | The TM1637 communication protocol is non-standard. It resembles the I2C protocol, but it is simpler and incompatible with I2C. Luckily, you can use a library and not worry about the implementation of the protocol. Here are some TM1637 libraries you can use on Arduino: RT1637_RT(https://github.com/RobTillaart/TM1637_RT), Grove 4-Digit Display.
32 |
33 | ## Simulator examples
34 |
35 | - [TM1637 Counter](https://wokwi.com/projects/339227323398095442)
36 | - [Three TM1637 displays](https://wokwi.com/projects/356661328560439297)
37 | - [TM1637 Thermometer (MicroPython on Pi Pico)](https://wokwi.com/projects/339373435833549395)
38 |
--------------------------------------------------------------------------------
/docs/guides/micropython.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: MicroPython on Wokwi
3 | sidebar_label: MicroPython
4 | description: Create and run MicroPython projects in Wokwi using the Raspberry Pi Pico simulator.
5 | keywords: [MicroPython, Wokwi, Raspberry Pi Pico, main.py, REPL, flash filesystem, MicroPython simulation]
6 | ---
7 |
8 | You can create and run MicroPython projects on Wokwi. Start from the [Raspberry Pi Pico MicroPython project template](https://wokwi.com/projects/new/micropython-pi-pico).
9 |
10 | ## Project structure
11 |
12 | All MicroPython projects must include a `main.py` file. MicroPython will automatically load and execute the code from `main.py` when you start the simulation.
13 |
14 | Wokwi copies all the project files into the Pico's flash filesystem. This means your project
15 | can include additional Python modules and you can import them from `main.py` or from the interactive
16 | REPL. Your project can also include custom data inside text files.
17 |
18 | You can get a list of all the files in the flash filesystem by running:
19 |
20 | ```python
21 | import os
22 | print(os.listdir('/'))
23 | ```
24 |
25 | # MicroPython REPL
26 |
27 | When the code in `main.py` terminates (or you interrupt it with Ctrl+C), you'll get into the MicroPython REPL. The REPL is an interactive prompt where you can type python commands and see the results immediately. Type `help()` for MicroPython API cheat sheet. To paste code into the REPL type Ctrl+E and enter paste mode.
28 |
29 | ## Project examples
30 |
31 | - [Blink with MicroPython](https://wokwi.com/projects/300504213470839309)
32 | - [MicroPython 7-Segment Display](https://wokwi.com/projects/300210834979684872)
33 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-ntc-temperature-sensor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ntc-temperature-sensor Reference
3 | sidebar_label: wokwi-ntc-temperature-sensor
4 | ---
5 |
6 | Analog temperature sensor: NTC (negative temperature coefficient) thermistor.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ---------------------- |
14 | | VCC | Positive power supply |
15 | | OUT | Output signal (analog) |
16 | | GND | Ground |
17 |
18 | ## Attributes
19 |
20 | | Name | Description | Default value |
21 | | ----------- | -------------------------------------- | ------------- |
22 | | temperature | Initial temperature value (celsius) | "24" |
23 | | beta | The beta coefficient of the thermistor | "3950" |
24 |
25 | ## Reading the temperature
26 |
27 | The temperature sensor module includes a 10K NTC thermistor in series with a 10K resistor.
28 |
29 | This setup produces a voltage that depends on the temperature. You can read this voltage by
30 | connecting the OUT pin of the thermistor to an analog input pin and then using the
31 | `analogRead()` function.
32 |
33 | Use the following code to convert the return value of `analogRead()` into a temperature value (in celsius):
34 |
35 | ```cpp
36 | const float BETA = 3950; // should match the Beta Coefficient of the thermistor
37 | int analogValue = analogRead(A0);
38 | float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
39 | ```
40 |
41 | ## Simulator examples
42 |
43 | - [NTC Thermistor Basic Example](https://wokwi.com/projects/299330254810382858)
44 |
--------------------------------------------------------------------------------
/src/components/LEDBullet.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { useEffect, useState } from 'react';
3 | import { LED } from './LED';
4 |
5 | declare global {
6 | namespace JSX {
7 | interface IntrinsicElements {
8 | 'wokwi-led': any;
9 | }
10 | }
11 | }
12 |
13 | interface ILEDBulletProps {
14 | title: string;
15 | color: string;
16 | children: React.ReactNode;
17 | }
18 |
19 | export function LEDBullet({ title, color, children }: ILEDBulletProps) {
20 | const [brightness, setBrightness] = useState(0);
21 | const [targetBrightness, setTargetBrightness] = useState(0);
22 |
23 | useEffect(() => {
24 | if (brightness == targetBrightness) {
25 | return;
26 | }
27 |
28 | const timer = setTimeout(() => {
29 | if (targetBrightness > brightness) {
30 | setBrightness(Math.min(brightness + 0.05, targetBrightness));
31 | } else {
32 | setBrightness(Math.max(brightness - 0.05, targetBrightness));
33 | }
34 | }, 10);
35 |
36 | return () => clearTimeout(timer);
37 | }, [brightness, targetBrightness]);
38 |
39 | const mouseOver = () => {
40 | setTargetBrightness(1);
41 | };
42 | const mouseOut = () => {
43 | setTargetBrightness(0);
44 | };
45 |
46 | return (
47 |
48 |
53 |
54 |
{title}.
{children}
55 |
56 |
57 | );
58 | }
59 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-dht22.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-dht22 Reference
3 | sidebar_label: wokwi-dht22
4 | ---
5 |
6 | Digital Humidity and Temperature sensor.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ------------------------------- |
14 | | VCC | Positive voltage |
15 | | SDA | Digital data pin (input/output) |
16 | | NC | Not connected |
17 | | GND | Ground |
18 |
19 | ## Attributes
20 |
21 | | Name | Description | Default value |
22 | | ----------- | -------------------------------------------- | ------------- |
23 | | temperature | Initial temperature value (celsius) | "24" |
24 | | humidity | Initial relative humidity value (percentage) | "40" |
25 |
26 | ## Controlling the temperature
27 |
28 | You can change the temperature and humidity values while the simulation is running.
29 | Click on the DHT22 sensor and a small popup window will open. Use the temperature and
30 | humidity sliders to change the values. Click "Hide" to close the popup window.
31 |
32 | :::warning
33 | If you are trying to read this sensor from the ESP32, use the "DHT sensor library for ESPx" library. Other DHT22 libraries may not work reliably on the ESP32. You can use this [example project](https://wokwi.com/projects/322410731508073042) as a starting point.
34 | :::
35 |
36 | ## Simulator examples
37 |
38 | - [DHTlib example](https://wokwi.com/projects/344892337559700051)
39 | - [DHT-sensor-library examples](https://wokwi.com/projects/344892587898831442)
40 | - [DHT22 on the ESP32](https://wokwi.com/projects/322410731508073042)
41 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-slide-potentiometer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-slide-potentiometer Reference
3 | sidebar_label: wokwi-slide-potentiometer
4 | ---
5 |
6 | Sliding variable resistor (linear potentiometer)
7 |
8 |
9 |
10 | The function and pin-out of the slide potentiometer are same as [wokwi-potentiometer](wokwi-potentiometer). Check out the [wokwi-potentiometer docs](wokwi-potentiometer) for more information.
11 |
12 | ## Attributes
13 |
14 | | Name | Description | Default value |
15 | | ------------ | -------------------------------------------------------------------------------------------------------------------------- | ------------- |
16 | | value | Initial value of the potentiometer, between 0 and 1023 | "0" |
17 | | travelLength | Travel length of the tip (mm). Controls the width of the potentiometer. Common values: "15", "20", "30", "45", "60", "100" | "30" |
18 |
19 | ### Examples
20 |
21 | | Result | Attrs |
22 | | ------------------------------------------------ | --------------------------- |
23 | | | `{ "travelLength": "15" }` |
24 | | | `{ "travelLength": "60" }` |
25 | | | `{ "travelLength": "100" }` |
26 |
27 | ## Simulator examples
28 |
29 | - [Slide potentiometer + Servo](https://wokwi.com/projects/297604176384360973) - Control a [servo](wokwi-servo) with a slide potentiometer
30 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-a4988.svg:
--------------------------------------------------------------------------------
1 |
33 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-ks2e-m-dc5.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: ks2e-m-dc5 Relay Reference
3 | sidebar_label: wokwi-ks2e-m-dc5 (relay)
4 | ---
5 |
6 | Double Pole Double Throw (DPDT) Relay
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ----- | ----------------------------------------------------- |
14 | | COIL1 | First terminal of the coil |
15 | | COIL2 | Second terminal of the coil |
16 | | P1 | First pole |
17 | | NC1 | Normally closed - connected to P1 when coil unpowered |
18 | | NO1 | Normally open - connected to P1 when coil powered |
19 | | P2 | Second pole |
20 | | NC2 | Normally closed - connected to P2 when coil unpowered |
21 | | NO2 | Normally open - connected to P2 when coil powered |
22 |
23 | ## Operation
24 |
25 | The relay is an electronic switch with two states: coil unpowered, and coil powered. By default, the coil is unpowered. You can power the coil by applying voltage between the pins COIL1 and COIL2.
26 |
27 | When the coil is unpowered, P1 is connected to NC1, and P2 is connected to NC2 (NC means normally closed/connected).
28 |
29 | When the coil is powered, P1 is connected to NO1, and P2 is connected to NO2 (NO means normally open/disconnected).
30 |
31 | The following diagram summarizes the states of the relay:
32 |
33 | 
34 |
35 | ## Simulator Examples
36 |
37 | - [One relay controlling two LEDs](https://wokwi.com/projects/322846360729551444)
38 | - [Relay Flip-Flop](https://wokwi.com/projects/322802227591774802) - Single bit memory element using three relays
39 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-max7219-matrix.svg:
--------------------------------------------------------------------------------
1 |
48 |
--------------------------------------------------------------------------------
/docs/wokwi-ci/mcp-support.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Model Context Protocola (MCP) support
3 | sidebar_label: MCP support
4 | description: Integrate AI agents like Copilot, Claude, Cursor, Gemini, and ChatGPT with Wokwi using the Model Context Protocol (MCP). This guide covers configuring the Wokwi MCP server, enabling real-time simulation, automated testing, and virtual hardware interaction.
5 | keywords: [MCP, Model Context Protocol, AI integration, Copilot, Claude, ChatGPT, Gemini, Cursor, automated testing, serial console]
6 | ---
7 |
8 |
9 | # MCP Support
10 |
11 | The Model Context Protocol (MCP) is an open standard that allows AI agents—such as Copilot, Claude Code, Cursor, Gemini, ChatGPT and others to securely interact with external tools and services. For Wokwi users, MCP enables seamless integration between AI assistants and embedded simulation.
12 |
13 | ## Wokwi MCP Server
14 |
15 | The Wokwi CLI includes an experimental MCP server that allows AI agents to interact with Wokwi's simulation and testing capabilities. This enables AI agents to:
16 |
17 | - Simulate complex embedded systems
18 | - Run automated tests on embedded projects
19 | - Monitor the serial console output and logs
20 | - Interact with the virtual hardware in real-time
21 |
22 | ## Configuration
23 |
24 | To configure your AI agent to use the Wokwi MCP server, add the following to your agent's MCP configuration:
25 |
26 | ```json
27 | {
28 | "servers": {
29 | "Wokwi": {
30 | "type": "stdio",
31 | "command": "wokwi-cli",
32 | "args": ["mcp"],
33 | "env": {
34 | "WOKWI_CLI_TOKEN": "${input:wokwi-cli-token}"
35 | }
36 | }
37 | }
38 | }
39 | ```
40 |
41 | ### Authentication
42 |
43 | You will need a valid Wokwi CLI token to use the MCP server. You can generate a token in the [Wokwi CI Dashboard](https://wokwi.com/dashboard/ci).
44 |
--------------------------------------------------------------------------------
/static/img/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-led-bar-graph.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-led-bar-graph Reference
3 | sidebar_label: wokwi-led-bar-graph
4 | ---
5 |
6 | 10-segment LED Bar Graph.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ------ | ---------------------------------------------- |
14 | | A**n** | Anode (positive pin) of LED **n** (n = 1…10) |
15 | | C**n** | Cathode (negative pin) of LED **n** (n = 1…10) |
16 |
17 | e.g. A1 is the anode of the top LED, and C1 is the cathode of the top LED.
18 |
19 | ## Attributes
20 |
21 | | Name | Description | Default value |
22 | | ----- | ------------------------------------------------------------------------ | ------------- |
23 | | color | The color of the LED body, or one of the special values "GYR" / "BCYR"\* | "red" |
24 |
25 | \* GYR means Green-Yellow-Red. BCYR means Cyan-Blue-Yellow-Red
26 |
27 | ### Examples
28 |
29 | | Result | Attrs |
30 | | ----------------------------------------------------------------------- | ------------------------ |
31 | | | `{ "color": "yellow" }` |
32 | | | `{ "color": "#9EFF3C" }` |
33 | | | `{ "color": "GYR"}` |
34 | | | `{ "color": "BCYR"}` |
35 |
36 | ## Simulator examples
37 |
38 | - [Arduino LED Graph Bar](https://wokwi.com/projects/309829489359061570) - Move the potentiometer knob to control the LEDs
39 | - [Raspberry Pi Pico Binary Counter](https://wokwi.com/projects/309828467927548481)
40 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-nlsf595.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-nlsf595 Reference
3 | sidebar_label: wokwi-nlsf595
4 | ---
5 |
6 | Serial (SPI) Tri-Color LED Driver
7 |
8 | 
9 |
10 | Use the NLSF595 shift register to connect power-hungry RGB LEDs to your microcontroller. A single unit can control two RGB LEDs, and a chain of two units can control up to five RGB LEDs.
11 |
12 | ## Pin names
13 |
14 | | Pin | Description |
15 | | ----- | ------------------------------------------------------ |
16 | | SI | Serial input |
17 | | SCK | Serial clock |
18 | | RCK | Storage (latch) pin |
19 | | OE | Output enable, active low. Connect to GND if not used. |
20 | | QA…QH | Parallel output |
21 | | SQH | Serial output\* |
22 | | SCLR | Reset (clear), active low. Connect to VCC if not used |
23 | | GND | Ground |
24 | | VCC | Supply voltage |
25 |
26 | \* Use the Q7S to chain multiple NLSF595 units together. Connect SQH to the SI pin of the next NLSF595 chip in chain.
27 |
28 | ## Using the NLSF595
29 |
30 | You will need to connect at least 3 pins to your microcontroller: SI, SCK, and RCK.
31 |
32 | The OE pin can be used to disable the output of the shift register. If you need that functionality,
33 | connect it to your microcontroller. Otherwise, connect it to the ground to permanently enable the output.
34 |
35 | The output pins of the shift register, QA through QH, are usually connected to the input pins of common-anode [RGB LEDs](wokwi-rgb-led).
36 |
37 | ## Simulator examples
38 |
39 | - [NLSF595 LED Driver with 2 RGB LEDs](https://wokwi.com/projects/315085666329297472)
40 |
--------------------------------------------------------------------------------
/src/css/custom.css:
--------------------------------------------------------------------------------
1 | /* stylelint-disable docusaurus/copyright-header */
2 | /**
3 | * Any CSS included here will be global. The classic template
4 | * bundles Infima by default. Infima is a CSS framework designed to
5 | * work well for content-centric websites.
6 | */
7 |
8 | /* You can override the default Infima variables here. */
9 | :root {
10 | --ifm-color-primary: #25c2a0;
11 | --ifm-color-primary-dark: rgb(33, 175, 144);
12 | --ifm-color-primary-darker: rgb(31, 165, 136);
13 | --ifm-color-primary-darkest: rgb(26, 136, 112);
14 | --ifm-color-primary-light: rgb(70, 203, 174);
15 | --ifm-color-primary-lighter: rgb(102, 212, 189);
16 | --ifm-color-primary-lightest: rgb(146, 224, 208);
17 | --ifm-code-font-size: 95%;
18 | }
19 |
20 | figure {
21 | margin-top: 56px;
22 | }
23 |
24 | figure > img {
25 | display: block;
26 | }
27 |
28 | figcaption {
29 | text-align: center;
30 | margin-top: 10px;
31 | color: rgb(117, 117, 117);
32 | line-height: 20px;
33 | font-size: 14px;
34 | }
35 |
36 | .docusaurus-highlight-code-line {
37 | background-color: rgb(72, 77, 91);
38 | display: block;
39 | margin: 0 calc(-1 * var(--ifm-pre-padding));
40 | padding: 0 var(--ifm-pre-padding);
41 | }
42 |
43 | .simulator-link {
44 | font-weight: bold;
45 | color: orange;
46 | }
47 |
48 | html .svg-font-table {
49 | fill: currentColor;
50 | max-width: 100%;
51 | height: auto;
52 | }
53 |
54 | html[data-theme='light'] .svg-font-table #symbols {
55 | fill: rgb(0, 0, 255);
56 | }
57 |
58 | html[data-theme='dark'] .svg-font-table #symbols {
59 | fill: seagreen;
60 | }
61 |
62 | wokwi-analog-joystick[disabled] {
63 | display: inline-block;
64 | position: relative;
65 | }
66 |
67 | wokwi-analog-joystick[disabled]:before {
68 | position: absolute;
69 | content: ' ';
70 | top: 0;
71 | right: 0;
72 | left: 0;
73 | bottom: 0;
74 | }
75 |
76 | .led-bullet {
77 | display: flex;
78 | }
79 |
80 | .led-bullet span p {
81 | display: inline;
82 | margin: 0;
83 | }
84 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-pir-motion-sensor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-pir-motion-sensor Reference
3 | sidebar_label: wokwi-pir-motion-sensor
4 | ---
5 |
6 | Passive Infrared (PIR) motion sensor.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ---------------- |
14 | | GND | Ground |
15 | | OUT | Output (digital) |
16 | | VCC | Supply voltage |
17 |
18 | ## Attributes
19 |
20 | | Name | Description | Default value |
21 | | ----------- | --------------------------------------------------------------------------- | ------------- |
22 | | delayTime | The number of seconds OUT pin will stay high | "5" |
23 | | inhibitTime | The number of seconds the sensor will ignore motion when OUT returns to low | "1.2" |
24 | | retrigger | Set to "0" to disable retriggering | "" |
25 |
26 | ## Using the sensor
27 |
28 | To trigger the PIR motion sensor:
29 |
30 | 1. Select the sensor by clicking on it (while the simulation is running).
31 | 2. A small popup window will open. Click on "Simulate Motion".
32 |
33 | Triggering the sensor will drive the OUT pin high for 5 seconds (delay time),
34 | and then go low again. The sensor will ignore any further input for the
35 | next 1.2 seconds (inhibit time), and then start sensing for motion again.
36 |
37 | You can adjust the high duration of the OUT pin by setting the delayTime
38 | attribute (on a physical sensor you use a potentiometer to set the delay).
39 |
40 | The default setting of the sensor is to retrigger: the sensor keeps checking
41 | for motion while the OUT pin is high. It will extend the delay time every
42 | time another motion event is detected. You can disable this behavior by
43 | setting the "retrigger" attribute to "0".
44 |
45 | ## Simulator examples
46 |
47 | - [PIR sensor example (from AdaFruit)](https://wokwi.com/projects/299284655047180808)
48 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-buzzer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-buzzer Reference
3 | sidebar_label: wokwi-buzzer
4 | ---
5 |
6 | A piezoelectric buzzer
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | ----------- |
14 | | 1 | Negative(Black) pin |
15 | | 2 | Positive(Red) pin |
16 |
17 | ## Attributes
18 |
19 | | Name | Description | Default value |
20 | | ------ | -------------------------------------------------------- | ------------- |
21 | | mode | Buzzer operation mode: "smooth" or "accurate" | "smooth" |
22 | | volume | Volume (loudness) of the sound, between "0.01" and "1.0" | "1.0" |
23 |
24 | ### Operation modes
25 |
26 | The buzzer can operate in two modes: "smooth" (the default) and "accurate".
27 |
28 | "smooth" sounds better and is suitable for simple, single-frequency tones. Use it
29 | when playing a melody or playing tones with Arduino's `tone()` function. Complex and
30 | polyphonic sounds may not play correctly (or not play at all) in "smooth mode"
31 |
32 | Use the "accurate" mode when you need to play complex sounds. It will accurately play
33 | the sound you feed in. However, it'll add audible click noises to your sound. These noises
34 | are due to fluctuations in the simulation speed - it's not always able to provide the complete
35 | sound buffer in real time.
36 |
37 | ## Arduino example
38 |
39 | Connect pin 1 of the buzzer to Arduino GND pin, and pin 2 of the buzzer to Arduino pin 8. Then use the `tone()` function to play a sound:
40 |
41 | ```cpp
42 | tone(8, 262, 250); // Plays 262Hz tone for 0.250 seconds
43 | ```
44 |
45 | ## Simulator examples
46 |
47 | - [Simon game](https://wokwi.com/projects/344891334169985618) - A memory game with 4 push buttons
48 | - [Diatonic piano](https://wokwi.com/projects/291958456169005577) - An 8-note piano, use keys 1-8 to press the buttons and play the notes.
49 | - [Alarm clock](https://wokwi.com/projects/297787059514376717) - Uses the buzzer to play the alarm sound
50 |
--------------------------------------------------------------------------------
/docs/chips-api/analog.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Analog API
3 | sidebar_label: Analog API
4 | ---
5 |
6 | # Analog API
7 |
8 | ### float pin_adc_read(pin_t pin)
9 |
10 | Measures the current voltage on the given pin, and returns it. The pin must be set to `ANALOG` mode, otherwise the return value of this function is undefined. Note that Wokwi is a digital simulator with basic analog support, so there is currently very limited analog simulation. Some parts which support analog output include the [potentiometer](../parts/wokwi-slide-potentiometer), [NTC temperature sensor](../parts/wokwi-ntc-temperature-sensor), [photoresistor](../parts/wokwi-photoresistor-sensor), and [analog joystick](../parts/wokwi-analog-joystick).
11 |
12 | ### void pin_dac_write(pin_t pin, float voltage)
13 |
14 | Sets the analog voltage on the given pin. Currently, the reference voltage for all the virtual ADCs is 5 volts (regardless of the MCU), so setting the voltage to 0 will return the minimum value, and setting the voltage to 5 will return the maximum value (that is 1023 on Arduino). This may change in the future.
15 |
16 | This method can be called before setting the pin to `ANALOG` mode, but the voltage will only update once the pin mode is set to `ANALOG`.
17 |
18 | ## Simulator examples
19 |
20 | - [Analog API chip example](https://wokwi.com/projects/330112801381024338) -- Simulates a 0-5V/0-ADC_MAX voltage source. One float attribute and one analog output.
21 | - [Dual Op-Amp chip example](https://wokwi.com/projects/409320061010147329) -- Simulates a dual Op-Amp with 4 analog inputs, 2 analog outputs, 2 float attributes.
22 | - [R-C filter](https://wokwi.com/projects/409325290405496833) -- Simulates a low-pass R-C filter with 1 analog input, one analog output, and 4 attributes.
23 | - [Signal generator and Scope](https://wokwi.com/projects/359331973918199809) -- Simulates a signal generator with 5 attribute inputs and 1 analog output, and a scope with 4 digital inputs, 4 analog inputs and 4 attribute inputs. Chip code for both in Wokwi tabs. ([Scope github](https://github.com/Dlloydev/Wokwi-Chip-Scope))
24 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-ds1307.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ds1307 Reference
3 | sidebar_label: wokwi-ds1307
4 | ---
5 |
6 | RTC (Real Time Clock) module with I2C interface and 56 bytes of NV SRAM.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | |------|------------------------------------------------------|
14 | | GND | Ground |
15 | | 5V | Positive voltage (5V) |
16 | | SDA | I2C data line |
17 | | SCL | I2C clock line |
18 | | SQW | Square wave output. Not available in the simulation. |
19 |
20 | The I2C address of the DS1307 is 0x68.
21 |
22 | ## Attributes
23 |
24 | | Name | Description | Default value |
25 | |------------|----------------------------------------------------------------------|---------------|
26 | | `initTime` | Initial time of the RTC: "0", "now", or a valid ISO 8601 date string | "now" |
27 |
28 | ## Simulation Behavior
29 |
30 | The simulated DS1307 is automatically initialized to the current system time when starting the simulation. It
31 | then keeps counting the time. You can override the initial time by setting the `initTime` attribute to a different
32 | value. The value can be either a valid ISO 8601 date string (e.g. "2019-11-19T11:41:56Z"), or one of the following
33 | special values:
34 |
35 | - "0" - Set the initial time to "2000-01-01T00:00:00Z"
36 | - "now" - Set the initial time to the current system time
37 |
38 | Note that "Z" at the end of the date string indicates that the time is in UTC, and not in the local time zone.
39 | If you omit the "Z", the time will be interpreted as local time.
40 |
41 | The code running in the simulation can update the date/time of the DS1307, and the DS1307 will keep track
42 | of the updated time.
43 |
44 | ## Simulator examples
45 |
46 | - [Reading current date/time using RTClib](https://wokwi.com/projects/305979285237137984)
47 | - [Alarm clock](https://wokwi.com/projects/297787059514376717)
48 |
--------------------------------------------------------------------------------
/docs/parts/board-ssd1306.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: board-ssd1306 Reference
3 | sidebar_label: board-ssd1306
4 | ---
5 |
6 | Monochrome 128x64 OLED display with I2C interface
7 |
8 | 
9 |
10 | The default I2C address of the SSD1306 module is 0x3c (60). Some modules have a different address (0x3d), you can change the address by editing diagram.json and setting the `i2cAddress` attribute to "0x3d".
11 |
12 | ## Pin names
13 |
14 | | Name | Description | Arduino Uno pin |
15 | | ---- | -------------- | --------------- |
16 | | GND | Ground | GND |
17 | | VCC | Supply voltage | 5V |
18 | | SCL | I2C clock line | A5 |
19 | | SDA | I2C data line | A4 |
20 |
21 | ## Attributes
22 |
23 | | Name | Description | Default value |
24 | | ---------- | -------------------------- | ------------- |
25 | | i2cAddress | I2C address of the display | "0x3c" |
26 |
27 | ## Using in Arduino
28 |
29 | You can choose between several SSD1306 Arduino libraries:
30 |
31 | - [Adafruit SSD1306](https://wokwi.com/projects/344892392214626898)
32 | - [ssd1306](https://wokwi.com/projects/344894074741850707)
33 | - [lcdgfx](https://github.com/lexus2k/lcdgfx)
34 | - [U8glib](https://github.com/olikraus/u8glib)
35 | - [U8g2](https://github.com/olikraus/u8g2) (also U8x8)
36 | - [SSD1306Ascii](https://github.com/greiman/SSD1306Ascii)
37 | - [Tiny4kOLED](https://www.arduino.cc/reference/en/libraries/tiny4koled/) - for ATtiny85 users
38 |
39 | All the above libraries are available on Wokwi.
40 |
41 | ## Simulator examples
42 |
43 | - [SSD1306 Snake Game](https://wokwi.com/projects/296135008348799496) (using Adafruit SSD1306)
44 | - [ATtiny85 Digital Temperature + Humidity on SSD1306](https://wokwi.com/projects/292900020514980360)
45 | - [U8glib Progress Bar](https://wokwi.com/projects/300867986768527882)
46 | - [SSD1306Ascii Fonts](https://wokwi.com/projects/291197274604700168)
47 | - [Adafruit SSD1306 Showcase](https://wokwi.com/projects/344892392214626898)
48 | - [U8g2 Menu](https://wokwi.com/projects/291572875238834696)
49 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-servo.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-servo Reference
3 | sidebar_label: wokwi-servo
4 | ---
5 |
6 | A standard Micro Servo Motor.
7 |
8 |
9 |
10 | ## Range of motion
11 |
12 | The servo is able to sweep from 0 degrees to 180 degrees, with hard stops at both ends.
13 |
14 | | | | |
15 | | :-------------: | :------------------------: | :-------------------------: |
16 | | 0 degrees | 90 degrees | 180 degrees |
17 |
18 | ## Pin names
19 |
20 | | Name | Description |
21 | | ---- | --------------------- |
22 | | PWM | Servo control signal |
23 | | V+ | Positive voltage (5V) |
24 | | GND | Ground |
25 |
26 | ## Attributes
27 |
28 | | Name | Description | Default value |
29 | | --------- | ---------------------------------------- | ------------- |
30 | | horn | Horn type: "single", "double" or "cross" | "single" |
31 | | hornColor | The color of the servo's horn | "#ccc" |
32 |
33 | ### Examples
34 |
35 | | Result | Attrs |
36 | | -------------------------------- | ---------------------------- |
37 | | | `{ "horn": "single" }` |
38 | | | `{ "hornColor": "#000088" }` |
39 | | | `{ "horn": "double" }` |
40 | | | `{ "horn": "cross" }` |
41 |
42 | ## Simulator examples
43 |
44 | - [Sweep](https://wokwi.com/projects/344891730528567891)
45 | - [ESP32 Servo Sweep](https://wokwi.com/projects/323706614646309460)
46 | - [Knob](https://wokwi.com/projects/344892191015961170)
47 | - [Arduino Nano controlling 1 servo with two pushbuttons](https://wokwi.com/projects/328312829780165204)
48 | - [Arduino Uno controlling 5 servos](https://wokwi.com/projects/305087394119418434)
49 | - [Arduino Mega animating 32 servos](https://wokwi.com/projects/305336312628511297)
50 |
51 | ## Tutorials
52 |
53 | - [Exploring servo motors using the Wokwi Logic Analyzer](https://blog.wokwi.com/learn-servo-motor-using-wokwi-logic-analyzer)
54 |
--------------------------------------------------------------------------------
/workers/auto-locale.js:
--------------------------------------------------------------------------------
1 | /*
2 | Automatically redirect users to their native language documentation, if available, based on the Accept-Language header
3 | sent from their browser. Runs on Cloudflare Workers.
4 |
5 | Copyright (C) 2021, Uri Shaked.
6 | Released under the terms of the MIT license.
7 | */
8 | /* SPDX-License-Identifier: MIT */
9 |
10 | const docsUrl = 'https://docs.wokwi.com';
11 |
12 | /**
13 | * @param {Request} request
14 | */
15 | function getLanguages(request) {
16 | const acceptLanguage = request.headers.get('Accept-Language');
17 | const result = [];
18 | for (const item of (acceptLanguage ?? '').split(',')) {
19 | const [lang, rest] = item.split(';');
20 | const quality = (rest ?? '').startsWith('q=') ? parseFloat(rest.substr(2)) : 1;
21 | result.push({ lang, quality });
22 | }
23 | return result;
24 | }
25 |
26 | /**
27 | * @param {ReturnType} langs
28 | * @param {string[]} supportedLangs
29 | * @param {string} defaultLang
30 | */
31 | function pickLanguage(langs, supportedLangs, defaultLang) {
32 | langs = [...langs].sort((a, b) => b.quality - a.quality);
33 | for (const { lang, quality } of langs) {
34 | if (supportedLangs.includes(lang.toLowerCase())) {
35 | return { lang, quality };
36 | }
37 | }
38 | return { lang: defaultLang, quality: 0 };
39 | }
40 |
41 | addEventListener('fetch', (event) => {
42 | event.respondWith(handleRequest(event.request).catch((err) => new Response({ status: 500 })));
43 | });
44 |
45 | /**
46 | * @param {Request} request
47 | * @returns {Promise}
48 | */
49 | async function handleRequest(request) {
50 | const { pathname } = new URL(request.url);
51 | const referer = request.headers.get('Referer');
52 | const secFetchSite = request.headers.get('Sec-Fetch-Site');
53 | const { lang } = pickLanguage(getLanguages(request), ['pt-br', 'pt', 'en'], 'en');
54 |
55 | if (secFetchSite !== 'same-origin' && (!referer || !referer.startsWith(docsUrl))) {
56 | if (
57 | lang.startsWith('pt') &&
58 | !pathname.startsWith('/pt-BR/') &&
59 | !pathname.startsWith('/assets/')
60 | ) {
61 | return Response.redirect(`${docsUrl}/pt-BR${pathname}`);
62 | }
63 | }
64 |
65 | return fetch(request);
66 | }
67 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-gas-sensor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-gas-sensor Reference
3 | sidebar_label: wokwi-gas-sensor
4 | ---
5 |
6 | MQ2 Gas Sensor module
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | --------------------- |
14 | | VCC | Positive power supply |
15 | | GND | Ground |
16 | | DO | Digital output |
17 | | AO | Analog output |
18 |
19 | ## Attributes
20 |
21 | | Name | Description | Default value |
22 | | --------- | ------------------------------------------------ | ------------- |
23 | | ppm | Initial gas concentration (in parts per million) | "400" |
24 | | threshold | Digital output threshold voltage | "4.4" |
25 |
26 | ## Operation
27 |
28 | The MQ2 Gas Sensor is a semiconductor sensor that can detect the presence of various combustible gases including LPG, Propane, Hydrogen, Methane, and Carbon Monoxide. The sensor has both analog and digital outputs:
29 |
30 | - The analog output (AO) provides a continuous voltage reading that corresponds to the gas concentration (ppm). Higher gas concentration results in higher voltage output.
31 | - The digital output (DO) acts as a threshold detector - it goes LOW when gas concentration exceeds the threshold set by the potentiometer.
32 |
33 | To use the MQ2 sensor:
34 |
35 | 1. Connect VCC to 5V power supply
36 | 2. Connect GND to ground
37 | 3. For analog readings:
38 | - Connect AO to an analog input pin
39 | - Read the analog value to get relative gas concentration
40 | 4. For threshold detection:
41 | - Connect DO to a digital input pin
42 | - The pin will read LOW when gas concentration exceeds threshold
43 | - Adjust threshold using the `threshold` attribute
44 |
45 | Note: In real hardware, the sensor needs a pre-heating time of about 20-30 seconds before taking readings. The simulator provides readings immediately.
46 |
47 |
48 | ### Digital output
49 |
50 | The digital output (DO) pin will read LOW when gas concentration exceeds the threshold. The threshold is set by the `threshold` attribute. The default threshold is 4.4V.
51 |
52 |
53 | ## Simulator examples
54 |
55 | - [MQ2 Gas Sensor Digital Example](https://wokwi.com/projects/424318978955716609)
56 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-slide-switch.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-slide-switch Reference
3 | sidebar_label: wokwi-slide-switch
4 | ---
5 |
6 | Standard Single Pole Double Throw (SPDT) slide switch.
7 |
8 |
9 |
10 | ## Pin names
11 |
12 | | Name | Description |
13 | | ---- | --------------- |
14 | | 1 | Left terminal |
15 | | 2 | Common terminal |
16 | | 3 | Right terminal |
17 |
18 | The slide switch has three pins. Pin 2 (in the middle) is the common pin. Depending on the position
19 | of the switch's handle, it's connected to either pin 1 or 3:
20 |
21 | | Handle position | Description |
22 | | --------------- | --------------------- |
23 | | Left | Shorting pins 1 and 2 |
24 | | Right | Shorting pins 3 and 2 |
25 |
26 | The following diagram illustrates the connections inside the slide switch. You can see the gray sliding
27 | contact that moves together with the handle and creates a connection between pin 2 and either pin 1 or 3:
28 |
29 | 
30 |
31 | ## Attributes
32 |
33 | | Name | Description | Default value |
34 | | ------ | -------------------------------------------------------------------- | ------------- |
35 | | value | Initial position of the slide switch: "" for left, "1" for right | "" |
36 | | bounce | Set to "0" to disable bouncing | "" |
37 |
38 | ### Bouncing
39 |
40 | When you move a physical slide switch, the circuit opens and closes tens or hundreds of times.
41 | This phenomenon is called [Bouncing](wokwi-pushbutton#bouncing).
42 |
43 | Wokwi simulates switch bouncing by default. You can disable the bouncing simulation for individual switches by setting their "bounce" attr to "0":
44 |
45 | `{ "bounce": "0" }`
46 |
47 | ## Simulator examples
48 |
49 | - [Slide Switch and LED](https://wokwi.com/projects/288276100805558797) - Using a slide switch to toggle an LED
50 | - [Slide Switch and 2 LEDs](https://wokwi.com/projects/288278249939665421) - A slide switch toggles between 2 LEDs
51 | - [Digital Pin Output Switching](https://wokwi.com/projects/292033853022798344) - A slide switch redirects the output of a digital pin to one of two LEDs
52 |
--------------------------------------------------------------------------------
/docs/parts/wokwi-ir-remote.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: wokwi-ir-remote Reference
3 | sidebar_label: wokwi-ir-remote
4 | ---
5 |
6 | 38KHz infrared remote with 20 function keys. Use together with the [IR Receiver module](wokwi-ir-receiver).
7 |
8 |
9 |
10 | ## Function keys
11 |
12 | The keys send infrared messages encoded using the [NEC frame format](https://exploreembedded.com/wiki/NEC_IR_Remote_Control_Interface_with_8051#NEC_Protocol). Each key sends a different command value (see the table below), and the address field is always 0.
13 |
14 | Each key has a keyboard shortcut that actives the key while the remote is in focus.
15 |
16 | The following table lists the NEC command, NEC encoded value and keyboard shortcut
17 | for each of the keys:
18 |
19 | | Key | Command | NEC encoded | Keyboard Shortcut |
20 | | -------- | ------- | ----------- | ----------------- |
21 | | Power | 162 | 0xFFA25D | O |
22 | | Menu | 226 | 0xFFE21D | M |
23 | | Test | 34 | 0xFF22DD | T |
24 | | Plus | 2 | 0xFF02FD | + |
25 | | Back | 194 | 0xFFC23D | B |
26 | | Previous | 224 | 0xFFE01F | Left arrow key |
27 | | Play | 168 | 0xFFA857 | P |
28 | | Next | 144 | 0xFF906F | Right arrow key |
29 | | 0 | 104 | 0xFF6897 | 0 |
30 | | Minus | 152 | 0xFF9867 | - (minus) |
31 | | C | 176 | 0xFFB04F | C |
32 | | 1 | 48 | 0xFF30CF | 1 |
33 | | 2 | 24 | 0xFF18E7 | 2 |
34 | | 3 | 122 | 0xFF7A85 | 3 |
35 | | 4 | 16 | 0xFF10EF | 4 |
36 | | 5 | 56 | 0xFF38C7 | 5 |
37 | | 6 | 90 | 0xFF5AA5 | 6 |
38 | | 7 | 66 | 0xFF42BD | 7 |
39 | | 8 | 74 | 0xFF4AB5 | 8 |
40 | | 9 | 82 | 0xFF52AD | 9 |
41 |
42 | ## Simulator examples
43 |
44 | - [IRRemote + LCD Display](https://wokwi.com/projects/298934082074575369)
45 | - [IRRemote + LCD Display with updated IRRemote API](https://wokwi.com/projects/408236279940409345)
46 |
--------------------------------------------------------------------------------
/docs/chips-api/time.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Time simulation API
3 | sidebar_label: Time API
4 | ---
5 |
6 | # Time simulation
7 |
8 | ### uint64_t get_sim_nanos()
9 |
10 | Returns the current simulator (virtual) time in nanoseconds.
11 |
12 | :::tip
13 | You can get the current time in microseconds by calling `get_sim_nanos() / 1000`, or in milliseconds by calling `get_sim_nanos() / 1000000`.
14 | :::
15 |
16 | ### timer_t timer_init(timer_config_t \*config)
17 |
18 | Initializes a new timer. Returns the identifier of the timer. Call `timer_start()` to start the timer, and define the `chip_timer_event()` callback to response to timer events.
19 |
20 | The `timer_config_t` struct contains the following fields:
21 |
22 | | Field | Type | Description |
23 | | ----------- | -------- | -------------------------------------------------------------- |
24 | | `callback` | callback | Called when the timer fires |
25 | | `user_data` | `void *` | Data that will be passed in the first argument to the callback |
26 |
27 | The signature for the callback function is as follows:
28 |
29 | ```cpp
30 | void chip_timer_callback(void *user_data) {
31 | /* Called when the timer fires */
32 | }
33 | ```
34 |
35 | :::warning
36 |
37 | Note: `timer_init()` can only be called from `chip_init()`. Do not call it at a later time.
38 |
39 | :::
40 |
41 | ### void timer_start(timer_t timer_id, uint32_t micros, bool repeat)
42 |
43 | Schedules the timer given by `timer_id`. The `micros` argument determines how many microseconds will pass until the timer will call `chip_timer_event()`. If `repeat` is `false`, the timer event will be called once (one-shot timer). If repeat is `true`, the timer event will keep getting called every `micros` microseconds, until you call `timer_stop()` or reconfigure the timer with `timer_start`.
44 |
45 | ### void timer_start_ns(timer_t timer_id, uint64_t nanos, bool repeat)
46 |
47 | Similar to `timer_start`, but specifies the duration of the timer in nanoseconds instead of microseconds. Prefer `timer_start()` when possible, in order to improve performance.
48 |
49 | ### void timer_stop(timer_t timer_id)
50 |
51 | Stops the given timer. If the timer hasn't fired yet, it won't fire until you call `timer_start()` again.
52 |
--------------------------------------------------------------------------------
/docs/wokwi-ci/cli-usage.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Wokwi CLI Usage
3 | sidebar_label: CLI Usage
4 | description: Wokwi CLI command reference
5 | keywords: [ reference, Wokwi, CLI, API, CI Dashboard, serial monitor]
6 | ---
7 |
8 | Create an API token on the [Wokwi CI Dashboard](https://wokwi.com/dashboard/ci). Set the `WOKWI_CLI_TOKEN` environment variable to the token value.
9 |
10 | If you haven't set up your project for Wokwi yet, you can use the `init` command to configure your project for Wokwi. Run the following command in your project's root directory:
11 |
12 | ```bash
13 | wokwi-cli init
14 | ```
15 |
16 | This command will ask you a few questions and will automatically generate [wokwi.toml](../vscode/project-config) and [diagram.json](../diagram-format) files for your project.
17 |
18 | To run the simulation, use the following command:
19 |
20 | ```bash
21 | wokwi-cli
22 | ```
23 |
24 | The CLI will start the simulation and display the serial output. It will automatically exit after 30 seconds.
25 |
26 | ## CLI Options
27 |
28 | You can use the following options to customize the CLI behavior:
29 |
30 | ### Configuration
31 |
32 | - `--elf ` - ELF file to simulate (default: read from wokwi.toml)
33 | - `--diagram-file ` - Path to the diagram.json file, relative to project root (default: diagram.json)
34 | - `--interactive` - Redirect stdin to the simulated serial port
35 | - `--serial-log-file ` - Save the serial monitor output to the given file
36 | - `--timeout ` - Timeout in simulation milliseconds (default: 30000)
37 | - `--timeout-exit-code ` - Process exit code when timeout is reached (default: 42)
38 |
39 | ### Automation
40 |
41 | - `--expect-text ` - Expect the given text in the output
42 | - `--fail-text ` - Fail if the given text is found in the output
43 | - `--scenario ` - Path to an [automation scenario](./automation-scenarios) file, relative to project root
44 | - `--screenshot-part ` - Take a screenshot of the given part id (from diagram.json)
45 | - `--screenshot-time ` - Time in simulation milliseconds to take the screenshot
46 | - `--screenshot-file ` - File name to save the screenshot to (default: screenshot.png)
47 |
48 | ### General
49 |
50 | - `--help`, `-h` - Prints help information and exit
51 | - `--quiet`, `-q` - Quiet: do not print version or status messages
52 |
--------------------------------------------------------------------------------
/docs/chips-api/attributes.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Attributes
3 | sidebar_label: Attributes
4 | ---
5 |
6 | # Attributes
7 |
8 | Attributes are input parameters that the user can set in `diagram.json`. You can also define a [`controls` section](./chip-json#controls) in the `.chip.json` file to let the user edit these parameters interactively during the simulation. This is particularly useful for sensor inputs (e.g. temperature, humidity, etc.).
9 |
10 | ### Naming
11 |
12 | When naming your attributes, please follow the following conventions:
13 |
14 | - Use `camelCase` for attribute names
15 | - Use American English spelling (e.g. `color` and not `colour`)
16 |
17 | ### uint32_t attr_init(const char \*name, uint32_t default_value)
18 |
19 | Defines a new integer attribute with the given name. The `default_value` will be used when the user does not define a value for the attribute in `diagram.json` (under the `attrs` section of the custom chip `part`).
20 |
21 | The function returns a handle to the attribute, which can be accessed using `attr_read()`.
22 |
23 | :::warning
24 |
25 | Note: `attr_init` can only be called from `chip_init()`. Do not call it at a later time.
26 |
27 | :::
28 |
29 | ### uint32_t attr_init_float(const char \*name, float default_value)
30 |
31 | Defines a new floating point attribute with the given name. See `attr_init()` for more info.
32 |
33 | :::warning
34 |
35 | Note: `attr_init_float` can only be called from `chip_init()`. Do not call it at a later time.
36 |
37 | :::
38 |
39 | ### uint32_t attr_read(uint32_t attr)
40 |
41 | Returns the current value of the attribute. `attr` should be a valid attribute handle, previously returned by `attr_init()`.
42 |
43 | ### float attr_read_float(uint32_t attr)
44 |
45 | Returns the current value of the attribute. `attr` should be a valid attribute handle, previously returned by `attr_init_float()`.
46 |
47 | ### Simulator Examples
48 |
49 | - [Analog API chip example](https://wokwi.com/projects/330112801381024338) -- Simulates a 0-5V/0-ADC_MAX voltage source. One float attribute and one analog output.
50 | - [PWM with Scope](https://wokwi.com/projects/354488725362438145) ([github](https://github.com/Dlloydev/Wokwi-Chip-PWM)) -- simulates a PWM input with 1 digital output and three attributes
51 | - [Scope with PWM](https://wokwi.com/projects/354488725362438145) ([Scope with muliple inputs](https://wokwi.com/projects/359330496025635841)) ([github](https://github.com/Dlloydev/Wokwi-Chip-Scope)) -- Simulates a 4-channel oscilloscope with 4 digital inputs, 4 analog inputs and 4 attributes
52 |
--------------------------------------------------------------------------------
/docs/guides/debugger.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Interactive debugger
3 | sidebar_label: Interactive debugger
4 | description: Use Wokwi's built-in interactive debugger to step through code, set breakpoints, inspect variables, and explore call stacks.
5 | keywords: [Wokwi debugger, interactive debugger, Arduino debug, step through, breakpoints]
6 | ---
7 |
8 |
9 | # Interactive debugger
10 |
11 | Wokwi has a built-in debugger that allows you to step through your code, inspect variables, and set breakpoints. The debugger is currently in beta, and is available for AVR microcontrollers: Arduino Uno, Arduino Nano, Arduino Mega, and the ATtiny85.
12 |
13 | If you wish to debug other microcontrollers, such as the ESP32 or the Raspberry Pi Pico, you can use [Wokwi for VSCode](../vscode/getting-started), which has [integrated debugger support](../vscode/debugging).
14 |
15 | ## Using the debugger
16 |
17 | To start debugging your code, click the menu button in the simulator toolbar, and select **Debug**:
18 |
19 | 
20 |
21 | You can set breakpoints by clicking on the left margin of the code editor. The debugger will pause the execution when the program reaches the breakpoint.
22 |
23 | When running in debug mode, you will see the debug toolbar above the code editor. The toolbar contains the following buttons:
24 |
25 | - **Continue** - Continue running the program. If the program is paused at a breakpoint, the debugger will continue running until the next breakpoint.
26 |
27 | - **Step over** - Step over the current line of code. If the current line is a function call, the debugger will step over the function call and stop at the next line of code.
28 |
29 | - **Step into** - Step into the current line of code. If the current line is a function call, the debugger will step into the function and stop at the first line of the function.
30 |
31 | - **Step out** - Step out of the current function.
32 |
33 | ## Debugging panes
34 |
35 | The debugging panes appear when you pause the program (either manually, or at a breakpoint). You'll find the panes below the diagram, next to the [Serial Monitor](./serial-monitor) pane.
36 |
37 | ### Call stack
38 |
39 | The call stack shows the current function call stack. The top of the stack is the currently executing function. The bottom of the stack is the main function.
40 |
41 | ### Variables
42 |
43 | The variables pane shows the current values of the variables in the current scope. The variables are grouped by scope: local variables and global variables (which also include register values).
44 |
--------------------------------------------------------------------------------
/src/theme/NotFound/Content/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import clsx from 'clsx';
3 | import Translate from '@docusaurus/Translate';
4 | import Heading from '@theme/Heading';
5 | import Link from '@docusaurus/Link';
6 |
7 | import WokwiCat from '/static/img/wokwi-cat.svg';
8 |
9 | export default function NotFoundContent({className}) {
10 | return (
11 |
12 |
13 |
14 |
15 |
18 | 404 :(
19 |
20 |
21 |
22 |
25 | Sorry, the page doesn't exist or has moved.
26 |
27 |
28 |
34 |
37 | homepage
38 |
39 |
40 | )
41 | }}>
42 | Let's go back to the homepage.
43 |
44 |