Introduction
In this tutorial, we will learn how to use the Tinkercad platform for Arduino Simulation. Tinkercad is one of the best platforms for circuit building and simulation, mainly because of its user-friendly interface. This tutorial will serve as a basis for circuit building using Arduino in Tinkercad. So let’s get started by getting familiar with the Tinkercad platform.
Creating an Account in Tinkercad
The first step is to create an account in Tinkercad. You can access the website by clicking here.
After visiting the website, click on SIGN UP to create a new account. Alternatively, you can directly login if you already have an account.
Next, click on CREATE A PERSONAL ACCOUNT to start with your account creation.
After that, you will be provided with several options to create an account.
You can either sign-up using your email ID, or sign in using your Google/Apple ID.
Once you sign in to the Tinkercad platform, you will be able to see the following interface.
Subsequently, click on the TINKER drop-down menu
As a result, you will be able to see many options. In order to get used to the platform, click on LEARNING CENTER.
Here, you will get lots of tutorials on how to use various sections of the platform.
Creating your first project
Now, in order to start making your circuit, click on the CIRCUITS option.
Following that, click on the CREATE NEW CIRCUIT option.
Now, let us make a simple Arduino simulation to make an LED blink.
The right-most part is the components section. Firstly, type in Arduino in the search bar. Drag out the Arduino into the workspace.
Similarly, choose a breadboard and an LED and drag them onto the workspace.
After placing the main components, the workspace would look as shown below. Click the ZOOM TO FIT (square icon) on the top-left to view the entire setup.
Now before making the connections, there are a few things to keep in mind about the breadboard. The first and the last 2 rows are internally connected (indicated by the blue markings). These rows are used for connecting the power supply(+) and the ground(-).
The holes in the middle (marked from A to J) are internally connected column-wise (indicated by the red markings). We place the components and connect them with each other using these holes.
Now, let’s start with the connections. Firstly, connect the cathode of the LED to the ground (GND) terminal of Arduino. Next, connect the anode of the LED to any of the digital pins (for eg. 9) of the Arduino. In order to limit the current flow through the LED, add a resistor (for eg. 1kΩ ) between the connection from the anode to the digital pin. The final setup would be as shown below
Coding the Arduino
Now, let’s dive into the coding part. For coding the Arduino, Tinkercad provides us with 3 options – BLOCKS, BLOCKS+TEXT, and TEXT. In this tutorial, we will be focusing on the TEXT option i.e coding using C++.
First, click on the CODE option on the top right side of the interface. Then, select the TEXT option of the Edit mode. As a result, a default template code will be visible as shown below
First, let’s look at the setup() function. The code that we write within the setup() function only runs once. Here, we use the pinMode() function to configure a pin as input/output. For our project, we configure pin 9 as the output by replacing the LED_BUILTIN with 9.
Next, let’s look at the loop() function. The code that we write within the loop() function keeps on getting executed until we stop the simulation. The digitalWrite() function is used to write (assign) a HIGH/LOW value to a pin. We do this in order to turn the LED ON/OFF respectively. Remember to replace the LED_BUILTIN parameter with the pin number (9).
We use the delay() function between the digitalWrite() functions in order to make the blinking action visible. So here, we use 1000 milliseconds as the delay time.
On making the necessary changes, the code will look as follows
Now, we’re ready to go for our first simulation! Click on START SIMULATION on the top right side, and see the LED blink ON and OFF!
Conclusion
So, we have successfully completed our first simulation project in Tinkercad. Also, if you are interested in knowing about the hardware implementation of blinking an LED using Arduino, you can click here. Hope that this tutorial was informative and worth your time.
Happy learning!