X
    Categories: AndroidCodingElectronicsTinkercad

Enhancing Circuits With Arduino in Tinkercad

The Arduino board is a microcontroller. A microcontroller is a very simple computer that accepts the simple code we create and translates that code into instructions that interact with the physical world. In this lesson, we will use a microcontroller to take the place of our switch. The microcontroller will do more than replace the switch. We will use the micro controller to augment what can be done with the circuit and a push button.

Build another circuit or modify the existing circuit from the previous lesson. Place one LED on the Breadboard and place two jump wires. Make sure to connect the anode wire to the positive lead and the cathode wire to the negative lead.

 

Click on the Components button and find the Arduino Uno R3 microcontroller.

 

Place the microcontroller to the left of the Breadboard. There are several components that are part of the Arduino board. Let’s look at a couple of these components.

 

The holes along both sides of the board are called GPIO pins. This stands for General Purpose Input/Output pins. Each is a connector that can be linked to our Breadboard with a jumper wire. Most of these are marked with a number. These numbers are used to identify the pins in our code. The code we develop on the board can reference these pins as either input or output. There is one connector labeled GND. This is the ground connector or the negative terminal in our circuit. The Arduino provides coded instructions to the components on the board and it also provides the necessary current to make the components work. The GND is the same as the negative terminal on a battery. The other connectors marked with a number are the same as the positive terminal on a battery.

A physical Arduino board is connected to a five-volt power supply from a computer USB port or from a battery pack. The Arduino itself can supply the same 5 volts to our components. For some components, this is too many volts or more accurately too much current. In our example, the 5 volts the current will destroy the LED on the Breadboard. We will be adding a resistor to limit the amount of current going to the LED.

 

The solid rectangle on the board with connectors coming out of the sides is the actual microcontroller. This is the component that handles all of our instructions and sends them to the components.

 

Connect a jumper wire from the GND connector to the negative column. Take another jumper wire and connect it from the number 3 connector to the positive column. There is nothing special about the number 3 in this example. We could have selected any of the other numbered connectors on the board. I moved the board slightly so you could see the connections. I also color coded the wires.

 

This isn’t enough to turn on the LED. We need to do a few more things. Click on the Code Editor button.

 

A coding panel will open at the bottom of the page. This coding panel uses puzzle blocks to develop code. This is very similar to blocks used in Code.org or Scratch. This the standard block of code include each time we place an Arduino board onto the workspace. This block of code will cause the LED on the Arduino board to blink. This is not the LED on our Breadboard. The Arduino has a small LED on the board. Click the Start Simulation button to see the LED blink on the board.

 

The blinking LED can be seen on the left side of the Arduino logo. Stop the simulation.

 

We don’t need this code because we want to turn on the LED located on the Breadboard. Click and drag the code to the trash can icon. Click on the first code block and drag it to the trash can icon.

 

We need a little more room to code. Move your mouse pointer to the top edge of the coding panel until you see the arrow change. Click and drag up to expand the coding panel.

 

The coding panel has different sections of code. We will be using code blocks in the Output section. Drag the set pin code onto the coding canvas.

 

Most code blocks have options that can be changed. This code block includes a pin number and a state. The PIN number references the connector we used to send current to on the Breadboard. This is the positive jumper wire we connected earlier. We connected the wire to pin 3. The options in the code block are called arguments. The term argument comes from mathematics. The argument of a function is a specific input to the function. It is an independent variable like the pin in our code block. This code block has two arguments.

 

Change the pin argument to 3. The second argument has two states. A state has one of two options. A state can be on or off. In this code block, the state is set to high. A high state is the same as an On state. The other option is a low state. This is the same as Off. Computers read everything as either On or off or ones and zeros. Binary numbers like one and zero are at the heart of all computers.

That’s all we need to get started. Click the Start Simulation button. Resize the code block panel to see the LED.

 

The LED will change color to indicate that it is on. There is an exclamation mark next to the LED. This exclamation mark is a warning. The current going through the LED is too high. In the simulation, we get a warning. In a physical board with a real LED the LED would burn out and won’t work again. This is why testing or prototyping on digital breadboards can be very useful until you learn the basics. LEDs aren’t expensive but expensive enough that you don’t want to be burning them out regularly.

To avoid burning out LEDs we need to use resistors. Resistors restrict the flow of current to components. Every circuit includes voltage, resistance, and current. Current is the part of the equation that does all the work. Think of electric current like water flowing through a river or stream. Resistance is the width of the river or stream. Narrow streams have more resistance than wide streams.

 

Stop the simulation and close the code editor. We need to make room of the resistor. Move the LED to the other side of the board and place it in column A. We need to leave room for the jumper wire and to see the connection in our illustration.

 

Open the components panel and find the resistor.

 

Place the resistor so it bridges the gap between the two halves of the board. Make sure the resistor is in the same row as the anode and the positive jumper wire.

 

Ok Time For Another Troubleshooting Problem

You might have already figured it out but I want to test your understanding anyway. Run the simulation. Why didn’t the LED turn on? Hint, is there a complete circuit?

The row connections do not span across the board between E and F. We can either place a jumper wire from F to E or place a jumper wire directly from the negative terminal column to row E. I added another jumper wire to complete the circuit.

 

Run the simulation and the LED should light.

 

Alex :