How to Simulate Arduino to Blink an LED Using Wokwi 2020
by sharepksn in Circuits > Arduino
2820 Views, 1 Favorites, 0 Comments
How to Simulate Arduino to Blink an LED Using Wokwi 2020
- No installations are needed π
- no downloads
- works on mobile π²
- just go to https://wokwi.com/
Supplies
Enthusiasm and any Browser
How to Simulate LEDs in Wokwi Arduino Simulator
In this tutorial, You will learn how to add an LED, connect it to an Arduino pin, and toggle it.
We will use AVG Secure browser in the tutorial but any browser is just fine.
Know the Basics of Wokwi Arduino Simulator
The Arduino Simulator window looks like this on the Wokwi platform. The left panel is for editing. You can edit your code, edit the connections, edit βπ½ the project descriptions, edit/add new header files/source files (this is also one of the advantages of wokwi Arduino Simulator over other kinds of simulators).
In the example image shown:
- blink.ino - Here you can edit the sketch. You can also paste the Arduino code from other websites or projects directly.
- Readme.md - Not a mandatory file but a useful practice to help yourself and others π to give a brief description of the project
- diagram.json - Heart π©Ί of the connections. here is where you will call all the elements (LEDs, UNO, Mega, Sensors, things, and stuff like that. You tell the Wowki Simulator on where to connect them here.
The first files are straight forward and hence we will focus on the third file π―. In the next step, we will see the basic layout and sections of the diagram.json file.
Tip: diagram.json name shouldn't be changed.
Basic Layout of the Wokwi Arduino Simulator's Diagram Editor
As you can see, at a higher level, in the wokwi Simulator we have the following three sections
- Basic information (something similar to metadata) - This is only for the information to give credits to the original co-author, mention the version)
- Parts section - Here is where you can add β the parts, here known as wokwi elements.
- Connections - You will connect the individual elements (complete the circuits)
In the next step, we will play around a little in the *.ino and the diagram.json tabs in the editor panel.
Tinker With the Example Arduino Blink Code
A small change is done in the Arduino blink sketch. The delayπΎ is reduced. you can try something different too.
We will now jump to the diagram.json window, I would say the heart of the wokwi Arduino simulator. π
Tinkering With the Diagram.json in the Editor Panel
The script file is easy to read and edit. The parameters can be kept all in one line or split into multiple lines(my favorite). As long as the script structure is followed with the appropriate code, it is fine.
In another step, I changed the LED type from red to blue. This will immediately reflect in the simulation window.
After changing the color parameter in the editor pane, the LED in the simulation window changed to blue π¦.
In the next step, we will see the connections. This is the final step in completing the circuit. β
Connecting the Wokwi Elements Together!
- The color of the wire can be changed
- The pins of the Arduino are pointed by UNO:1 or UNO:3 fro pin number 1 or pin number 3
- "uno" and "led" are the ID names. It can be literally anything. Meaningful ids are better
- The LED pins can be accessed as follows
- led:A - Anode pin
- led:C - Cathode pin
Note: The LEDs will work in the simulation as it is, but wait, in real life, we have to limit the current through the LED.
As of now, that's all. Our next step is to just hit the "START" button. π
START Button! - to Unleash the Magic of Arduino Simulator
Press the START button to start the simulations. thank you for following the last step π. if fact, this is the first step in getting involved in simulations, coding, open-source community coding, and beyond. π
Please spread the word about our Wokwi Arduino Simulator. For today, it is still a work in progress. It is getting better week by week.
Many people have directly and indirectly contributed to the Simulator. Please share your feedback via comments or direct messages. We will be glad to simulate πthat!
Thank you π
Other links you might be interested in πππ
https://www.instructables.com/Best-Free-Online-Wok...
https://www.instructables.com/Web-Based-Arduino-Si...
https://www.instructables.com/Online-Arduino-Simul...
https://www.instructables.com/How-to-Simulate-Ardu...