dark mode light mode Search Menu
Search

Tinkercad Circuits

SparkFun Electronics on Flickr

FOR THIS PROJECT YOU WILL NEED

  • An Arduino Uno (or compatible)
  • A computer with the Arduino IDE installed
  • An LED
  • A 330 Ohm resistor (Orange-Orange-Brown-Gold)
  • A 10K Resistor (Brown-Black-Orange-Gold)
  • Male to male jumper wires
  • A push button
  • Breadboard

The Arduino board has been with us for many years and it has become the brand leader in microcontrollers. It may not be as powerful as a Raspberry Pi, in fact the two are very different. But for sheer simplicity the Arduino cannot be beaten, all we need to do is write some code, upload it to the board, and away we go.

But here lies the issue. Learning the Arduino language, a version of C, can be off putting to new users. So when Tinkercad released their Circuits project, we had to have a try.

Tinkercard Circuits is an online tool to create virtual circuits using common electronics and boards such as the Arduino. We can build a circuit using components, then write code for the board using a block editor. We can even simulate our code before we upload it to a real Arduino.

In this project we will learn

  • How to create circuits using the Tinkercad Circuits editor
  • Write Arduino code with blocks
  • How to work with inputs
  • Control output devices
  • Use comments in our code
  • Upload code to an Arduino.

To use Tinkercad, first we need to visit https://tinkercad.com and sign up for an account.

Once we have an account we then need to login and then from the dashboard click on Circuits.

Then we need to click on Create New Circuit to load a blank project and the first task that we have is to make a basic circuit. The Tinkercad Circuits layout is simple. But a little cluttered at times. The main area, a large grey portion of the screen, is where we build our circuit. We get components, such as Arduino, LEDs, buttons etc from the right hand side of the screen. We click on the component and then move the mouse to the centre. We then see the component appear under the pointer.

Let’s start by adding an Arduino Uno to the project. From the components list look for “Arduino Uno R3” and drag that to the centre.

Now let’s add a breadboard in the same way.

And now add a button and LED to the breadboard.

Next we shall connect GND (Ground) from the Arduino to the GND (-) rail of the breadboard using a male to male jumper wire. This means that our circuit now has a common GND connection for all of the components used. To connect components, click on where you would like to start, in this case the GND pin on the Arduino, then click on where you want it to go, the – rail. To shape the wire, double left click on the wire and a node (circle) will appear, you can now move the wire around to form paths around the circuit.

Now we connect the 5V output on the Arduino to the bottom right leg of our button. Again we click on the connections that we wish to make.

Our pushbutton needs a pull down resistor. This is a resistor that is connected to the GND (-) rail of the breadboard, and its job is to ensure that we have a clear distinction between a button press, and not. When the button is not pressed, we need to ensure that our Arduino see 0V, so by pulling the button pin down to GND, we get 0V. When the button is pressed, it connects the button pin to 5V and that triggers our code to work.

Next we connect a 330 Ohm resistor from the short leg (cathode) of the LED to the GND – rail of the breadboard. This means that our LED is connected to GND.

Our button is used as an input to trigger our code, and so we need to connect it to a pin on the Arduino. Pin 2 is connected to the top left leg of the button via a male to male jumper wire. This means that when we press the button, pin 2 receives the 5V signal to trigger the code.

Our LED need to be connected to pin 7 as we shall be controlling this in our code later. In the same way as for our button, connect pin 7 to the anode (long leg) of the LED.

That is all of the connections made in Tinkercad, now we can concentrate on writing the code to control it.

Coding in Tinkercad Circuits is very similar to Scratch. We use blocks to build up the code step by step. The code section can be found by clicking the Code button, found in the top right of the screen.

In the coding section, delete any existing code by dragging it to the trash bin. The first block of code will be to create a comment in our code. Comments are great! We can use them to help others understand our code, and to remind ourselves on how we tackled the project.

Our button can have two states, on or off. But we need a way to store the state so that we can later check it. A variable is a container for our button state. So using the Variables section we create a new variable called “buttonState” and then drag the block “set buttonState to 0” into the coding area.

To store if the button has been pressed, we need to read the pin that it is connected to. This is found in “input” and it is called “read digital pin”, drag this into the 0 of “set buttonState to 0” and change the pin to 2. Now we can read the status of the button!

As we have two states for the button, our LED can also have two states. On or off. To correctly turn the LED on / off depending on if the button has been pressed, we need to use a conditional statement. This is really a way to ask a question, and depending on the result perform an action. In programming this is expressed as If…Else. We can find this block in Control.

So what is the question? Well has the button been pressed? If so then the buttonState variable will store a 1, otherwise a 0. This means on and off. From Math we drag the “1 < 1” block and place it into the corresponding shape in our “if” conditional test. Change the < to a = so that we compare the left value with the right. Now go to Variables and drag the “buttonState” block and place it over the first “1”. So now the question asks “Is the buttonState equal to 1?” which means has it been pressed?

So what happens if the button is pressed? The code inside the “if” section is activated, and now we need to go to Output and find the block “set pin 0 to HIGH”, drag one into the “If” section, and another into the “else” section. The block inside the “if” section will be changed to “set pin 7 to HIGH” as we need the LED to be lit when the button is pressed.
For the other “set pin 0 to HIGH” we need to change this to “set pin 7 to LOW” as the LED should be off if the button is not pressed.

But what if we want the LED to stay lit for a while? Well we need to go into Control and use a “wait 1 secs” block. Drag this into the “if” section, so that it is under “set pin 7 to HIGH”. Change 1 to 10 seconds so that we can see the change.

With the code completed we can now start the simulator. At the top of the screen is “Start Simulation” click on this button and wait for a few seconds. Then click on the button on our breadboard. You should now see the LED light up for 10 seconds, proving that our code and wiring is correct!

Here is a close up to show the LED reacting to the button press.

Building the circuit for real!

Using the circuit diagram, the circuit we created in Tinkercad Circuits. We can now build a real version of the project using our components. Connect everything as per the diagram.

Copying the code to our real Arduino

Our blocks of code can be translated into something that a real Arduino can understand, and so to do this we need to download the code. Just above the area where we wrote our code is a button showing an arrow pointing down. Click on this to download the code to your Downloads folder. Make a note of the file name as we need to find it later!

Now we move away from Tinkercad, and open the Arduino IDE. Click on File >> Open and go to your Downloads folder to locate the file. Open the file and you will see the code that makes our project happen!

Plug in your Arduino, which is connected to the circuit for this project. Then go to Tools >> Boards and make sure that the correct Arduino version is selected. Then go to Tools >> Port and check that the Arduino IDE can see your board.

Then when ready, click on the arrow pointing to the right to upload the code. After a few seconds the Arduino will reboot and you can now press the button on the real breadboard to control the LED!

So what have we learnt?

  • We learnt how to create a virtual circuit using Tinkercad Circuits, and how to connect components together to create a logical flow.
  • We learnt how to write code for the Arduino using blocks, and how to comment our code to explain the purpose of it.
  • We learnt how to use software to write a test to check if a physical, hardware, device has been used.
  • We learnt how to control an output device, an LED.
  • We learnt how to create variables and how to use them.

Learn More

Arduino Electronic Circuits in Tinkercad Tips and Tricks

https://www.youtube.com/watch?v=WOCRlmnMGRE

Pushbutton digital input

https://video.search.yahoo.com/yhs/search?fr=yhs-Lkry-SF01&hsimp=yhs-SF01&hspart=Lkry&p=arduino+with+tinkercad#id=4&vid=dbf6b35392e43c85faca50e7bfc2bc04&action=click

Connecting-an-Arduino-to-a-Breadboard-to-light-up

https://www.codeproject.com/Articles/1247033/Connecting-an-Arduino-to-a-Breadboard-to-light-up

Creating-an-Arduino-Board-Case-in-TinkerCad

https://airwolf3d.com/wp-content/uploads/2014/07/Creating-an-Arduino-Board-Case-in-TinkerCad.pdf

whack a mole game

https://www.instructables.com/id/Simon-Whack-a-Mole-Game-Using-Arduino/

basic-arduino-led-experiments

https://blog.tinkercad.com/2018/04/19/basic-arduino-led-experiments-in-tinkercad-circuits/

arduino printable relays for kids

https://images.search.yahoo.com/yhs/search;_ylt=AwrCmnqfHNJcOxgAQggPxQt.;_ylu=X3oDMTByMjB0aG5zBGNvbG8DYmYxBHBvcwMxBHZ0aWQDBHNlYwNzYw–?p=arduino+tinkercad+relay+for+kids+printable&fr=yhs-Lkry-SF01&hspart=Lkry&hsimp=yhs-SF01

Coupons: relays for arduino

https://www.dhgate.com/coupons/relay-for-arduino.html

tinkercad-circuits

https://www.norwegiancreations.com/2018/11/a-first-impression-of-tinkercad-circuits/

RGB LED Color Mixing with Arduino in TinkerCAD

https://www.pinterest.com/pin/664703226227152716/?lp=true