Articles, Blog

Blink an LED With Arduino in Tinkercad

September 12, 2019


Let’s learn how to blink an LED using Arduino’s
digital output. If you’re new to Arduino, this is a great
place to start. You can follow along virtually using Tinkercad
Circuits, then afterward grab your Arduino Uno board and a USB cable to create a physical
circuit. Take a look at the circuit in the workplane.
Click Start Simulation to watch the LED blink. You can use the simulator at any time to test
your circuits. The LED’s legs are connected to two pins
on the Arduino: ground and pin 13. This component between the LED and pin 13
is a resistor, which helps limit the current to prevent the LED from burning itself out.
Without it, you’ll get a warning that the LED might burn out soon.
It doesn’t matter whether the resistor comes before or after the LED in the circuit, or
which way around it goes. The colored stripes indicate the resistor’s value, and for this
circuit, anywhere from 100 ohms to 1000 ohms will work great. Click once to connect a wire
to a component or pin, and click again to connect the other end.
The LED, unlike the resistor, is polarized, which means it only works when the legs are
connected a certain way. The positive leg, called the anode, usually has a longer leg,
and is wired to power, in this case coming from your Arduino’s output pin 13. The negative
leg, called the cathode, with its shorter leg, connects to ground.
Did you notice the small LED flashing on the board itself? This built-in LED is also connected
to pin 13, and is meant to be used for testing purposes without the need to connect any external
components. It even has its own tiny resistor, soldered directly to the surface of the Arduino
board. Let’s look at the simple code controlling
the blink by checking out the code blocks editor.
The code starts out with two gray comment blocks, which are just notes for us humans
to read. The first blue output block sets the built-in
LED HIGH, which is Arduino’s way of describing “on.” This output command will activate
a 5V signal to connect anything connected to the specified pin.
Next up is a a yellow command block that waits for one second, simple enough. So the program
will pause while the LED is on for one second. Next, after another comment is a blue output
block to set the LED back to LOW, or “off,” followed by another second-long pause.
Try customizing this code by changing the wait times, and clicking Start Simulation.
You can even add more output and wait blocks to create longer flashing patterns.
In the text editor, you can see the Arduino code generated by the code blocks. All the
extra symbols are part of Arduino’s syntax, but don’t get intimidated. It takes time
to learn to write proper code from scratch! I’ll break it down for you here and you
can always use the blocks for reference as you level up.
This first section is title block comment, followed by the code’s setup, which helps
set up things your program will need later. It runs once when the program starts up. Our
blink sketch’s setup configures pin 13 as an output, which prepares the board to send
signals to it, rather than listen. The main body of the program is inside the
loop. This part of the code will execute on repeat, so long as the board has power. The
colored text following double slashes are also comments to help make the program easier
to understand. The output command we’re using is called
digitalWrite(), which is a function that sets a pin HIGH or LOW, on or off.
To pause the program we’ll use delay(), which takes a number of milliseconds. One
second is 1000 milliseconds. Try it for yourself in Tinkercad Circuits!
Grab this circuit and code combo any time using the Starter available in the components
panel. To program your physical Arduino Uno, copy
the code from the window and paste it into an empty Arduino sketch, or click the Download
Code button and open the resulting file using your Arduino software.
Plug in your USB cable and select your board in the tools menu. Upload the code and watch
your onboard LED flash with the custom blink you created earlier!
Now that you know how to blink an LED using Arduino’s digital output, you’re ready to
try other Arduino exercises that utilize the digitalWrite() function. Try using a breadboard
to add more LEDs and code to control them in the next lesson.
Thanks for watching and learning how to blink an LED with Arduino and Tinkercad Circuits.
Check out the rest of our huge collection of interactive beginner electronics tutorials,
and even build circuits into your 3D designs. See you next time!

You Might Also Like

13 Comments

  • Reply Diego Lozano April 6, 2018 at 6:03 pm

    Super

  • Reply HARI THAPA May 7, 2018 at 2:26 am

    Hi, I like your video so much.
    But when i try with electrical pictures like bulb,switch and so on the app couldn't support that. So, do you have any solution for that?

  • Reply Kornelius Satria May 14, 2018 at 9:58 am

    Can i include RTOS (Real Time Operating System) in Tinkercad?

  • Reply Junho Kim May 21, 2018 at 1:25 am

    Thank you

  • Reply charles klein September 12, 2018 at 9:41 am

    the picture of this person is distracting and interferes with me seeing the full screen. their is no reason for me to see this person! its annoying! but thank you for not having drug music as you spoke like most people do. i would really like to see the full screen.

  • Reply Roqaia Arrfou October 2, 2018 at 6:42 am

    Thanks a lot

  • Reply Damnit Bobby October 29, 2018 at 6:41 am

    Thanks

  • Reply pHoEn|}{-GR December 17, 2018 at 8:01 am

    i dont like the delay function… it is useless, you should explain how to use time in tinkercad

  • Reply Morwic December 17, 2018 at 6:19 pm

    so happy your back !!!

  • Reply sydney mcreynolds February 7, 2019 at 7:58 pm

    hey

  • Reply AtOm GaMe March 21, 2019 at 2:32 pm

    idi na

  • Reply AtOm GaMe March 21, 2019 at 2:38 pm

    бан илье

  • Reply youcef benchaabane March 27, 2019 at 1:51 pm

    hi i want to ask you haw to add bluetooth in tinkercad ,thank you

  • Leave a Reply