LEDs & Breadboards With Arduino in Tinkercad

Let's learn how to control multiple LEDs usingArduino’s digital outputs and a breadboard.

We'll connect some LEDs to the Arduino Unoand compose a simple program to light them up in a pattern.

Take a look at the workplane, where I’lladd a breadboard from the components panel.

The rows of a solderless breadboard are connectedinside, allowing you to connect components by plugging them into the same row as eachother.

The special long rails along the edges arefor easy access to power and ground.

It’s a best practice to always connect 5Vand ground to these long rails as a starting point for any Arduino circuit.

Try it for yourself in Tinkercad Circuits! Double click along the wire to create bendsyou can use to tidy up your circuit.

To change your wire colors, select the colorin the inspector, or use the number keys on your keyboard to quickly switch between colors.

Wire connections to 5V are typically red, and those connected to ground are typically black.

Let’s recreate the blink circuit using thebreadboard.

Add an LED to the breadboard so its legs gointo two different rows of the breadboard.

If your breadboard's up and down you can usethe rotate tool.

Attach wires to any of the holes in the samerow to make an electrical connection.

Just like before, we want to connect the LEDand resistor in series to pin 13 and ground.

This breadboard circuit is electrically identicalto this free-wired circuit.

You can build either way in the editor, butif you are also building a circuit with physical components, the breadboard will help keepyour virtual circuit looking the same.

Let’s add a few more LEDs to this circuit, along with their companion resistors.

For each, connect one end to ground, in thiscase through the resistor, and the other to a different digital input pin on the Arduinoboard.

Let’s use the code blocks editor to createthis animation effect.

To make the speed of the animation adjustable, add in a variable that will serve as the amount of time between state changes.

I’m going to call mine “animationSpeed.

” At the beginning of the program, set the variableto your desired time, in milliseconds.

Drag the new variable onto the wait blockto set it to whatever animationSpeed is set to.

Don't forget to do the dropdown for milliseconds.

Use another output block to set the next pin12 HIGH, then LOW, with another pause after each.

Duplicate this block for as many LEDs as youhave left, and change the pin numbers to correspond to the connected LEDs.

Test out your code by starting the simulator.

In the text editor, you can see the Arduinocode generated by the code blocks.

Before the setup(), we can see our variableis created.

It’s called int because it’s an integer, or any whole number.

Inside the setup, just like last time, thepins are configured to be outputs, rather than inputs, using the pinMode() function.

The code inside the loop looks familiar, too, using digitalWrite() to set the pins HIGH and LOW, on and off, and pausing in betweenfor a number of milliseconds.

And see, because we created the variable animationSpeed, if we change that number once at the start of the program, it will affect all of theplaces in the program that reference it.

So in this case, changing the variable animationSpeedwill control the pauses, and therefore the overall speed of the animation.

You can wire up your your physical ArduinoUno to look like the simulated one, then copy the code from the window and paste it intoan empty Arduino sketch, or click Download Code and open the resulting file using yourArduino software.

Notice how Tinkercad Circuits will highlightthe connected pins when you hover over a row.

And you can also refer back to this photoof the breadboard's inside.

Notice how Tinkercad Circuits will highlightthe connected pins when you hover over a row, and you can also refer back to the photo ofthe breadboard’s inside.

You’ll get plenty of breadboard practicein the upcoming lessons, and become a pro prototyper in no time! Now that you’ve learned to use a breadboardand code for digital outputs, you're ready to try even more fun stuff.

Try learning to fade an LED using analogWrite(), or skip ahead to learn to detect inputs with pushbuttons and digitalRead().

Thanks for watching and learning with TinkercadCircuits.

Check out the rest of our huge collectionof interactive beginner electronics tutorials, and even build circuits into your 3D designs.

See you next time!.

Leave a Reply