13.ฝึก Arduino โดยไม่มีบอร์ดด้วย Wokwi

https://wokwi.com/

A recent article introduced three popular Arduino simulators for makers. One of them is the Wokwi Arduino Simulator, an online circuit simulation tool aimed at more experienced makers. This article discusses the main features of the Wokwi Arduino Simulator and how you can get started with using it in practically no time.

Creating New Projects

To get started, navigate to the Wokwi Simulator website. From there, you’ll see the following dashboard. You can use the app for free and without creating a user account.

Getting Started with the Wokwi Arduino SimulatorThis image shows the Wokwi Arduino Simulator starting page, where you can create a new project by choosing one of the available development boards.

The app’s start page displays three popular development boards that you can choose from for your custom designs. However, the website supports more development boards and MCUs such as the Raspberry Pi Pico and the ATTiny85. You can find these options by clicking the More Options button. Once you select a board, the app opens a new simulator project:

Getting Started with the Wokwi Arduino SimulatorThis image outlines the most important elements in the app’s UI.

As you can see, the simulator view is divided into two main panels that you can resize if you like. On the left-hand side, you can see the code editor. Here, you can define the behavior of the selected development board. Note that this editor contains tabs that you can switch between. On the right side, you see the simulator, which lets you add components to your design and connect them to the development board. Note that, unlike other online circuit simulation programs, the Wokwi Arduino Simulator requires you to manually select, place, connect, and program all components in your design.

Working with the Wokwi Arduino Simulator

As mentioned, you have to place all components in the diagram and connect them to the development board. You also have to write the source code yourself. For that purpose, the Wokwi Arduino Simulator offers an exceptional code editor that even includes an auto-complete feature.

Getting Started with the Wokwi Arduino SimulatorThe code editor offers advanced features such as suggestions.

Note that the simulator does not fully implement some features of certain development boards. You can find more details in the app’s documentation. Either way, you can add components to your design by clicking on the purple plus-icon in the simulator on the right-hand side of the app. You can then connect components by dragging wires between them.

Unfortunately, the Wokwi Arduino Simulator does not offer a way to change component values or wire attributes such as their color by using the graphical UI. Instead, you have to click the diagram.json tab in the code editor panel. There, you can see a textual description of your design. You can then change the component values by adjusting the JSON document in the text editor.

Getting Started with the Wokwi Arduino SimulatorUnfortunately, you have to use the text editor to change component values in your design.

Once you finish your design, you can click the green play button in the simulator view to start the simulation. The simulation is interactive, and it allows you to push buttons, slide switches, and perform other actions to interact with your circuit.

Getting Started with the Wokwi Arduino SimulatorThe simulation is accurate, and the simulation speed is good.

The simulation is fairly accurate. However, note that this app is not meant to be used as full-fledged professional simulation software. As the name implies, it’s a tool for simulating digital Arduino-based circuits. When used correctly, the app does correctly simulate the parts in a design. It does, for example, accurately mimic button bounce and other phenomena you’d encounter when working with physical components. In addition, the simulation speed is good, and the circuit reacts to inputs as expected.

Loading External Libraries to Build More Advanced Circuits

You can add external libraries to your project if your design requires them to function. To do that, click the library manager tab located above the code editor:

Getting Started with the Wokwi Arduino SimulatorThe application’s library manager lets you extend the functionality of your projects by adding external libraries.

Then, click the purple add button. Doing so opens a pop-up that lets you search for various Arduino libraries. If you can’t find the library you’re looking for, you can also upload external libraries as a zip archive.

Summary

The Wokwi Arduino Simulator is a great online tool for simulating projects that use a development board. The app supports various popular development boards and MCUs such as the Arduino UNO, the Raspberry Pi Pico, the ESP32, and the ATTiny85.

The simulation program uses a straightforward workflow. You define the behavior of the development board using source code, and then you add the necessary components to your design. Unfortunately, the Wokwi simulator graphical user interface does not allow you to change wire colors and component values, such as the resistance of a resistor. Instead, you have to define these values in the tool’s text editor. However, the text editor offers advanced code suggestions and a handy autocomplete mechanism. Furthermore, you can add external libraries to your project to extend the functionality of your design.

Link:https://www.digikey.com/en/maker/tutorials/2022/getting-started-with-the-wokwi-arduino-simulator