Introduction: How to Blink an Led - Arduino Tutorial

Picture of How to Blink an Led - Arduino Tutorial

LEDs (Light-emitting diode) can be found on many collors and sizes.

This example shows the simplest thing you can do with an Arduino to see physical output: it blinks an LED!

In this tutorial you will also learn how to use pinMode(), digitalWrite() and delay() functions.

If you're new to Arduino this tutorial will help you get started and make your first Arduino project!

So, let's get started!

Step 1: What You Will Need

Picture of What You Will Need

For this tutorial you will need:

  • Arduino uno
  • Breadboard
  • LED
  • 220 Ohm resistor

If you would like you can also use breadboard shield for arduino uno.

Step 2: The Circuit

Picture of The Circuit

Common leds have two pins. The positive end of a led (larger pin) is called anode, and the negative end is called cathode.

Arduino uno board have a built-in LED on pin 13, but in this tutorial we are going to be adding our own on digital pin 3.

The connections are pretty easy, see the image above with breadboard circuit schematic.

Step 3: The Code

Here's the Blink code, embedded using codebender!

Keep in mind that setup( ) routine runs only once after power on / re-program or press the reset button. In the program below, the first thing you do is to initialize pin 3 as an output pin with pinMode( ) function in setup( ) routine.

The loop( ) routine runs over and over again, forever. In the main loop, you turn on or off LED with digitalWrite( ) function and "pause" the program for three seconds with delay( ) function. (3 sec are 3000 ms)

Try downloading the codebender plugin and clicking on the Run on Arduinobutton to program your Arduino with the Blink sketch. And that's it, you've programmed your first Arduino with the basic Blink sketch! You can keep playing with that by clicking the "Edit" button and start making your own modifications to the code. For example you can add a second led or change the delay time ;)

Step 4: Well Done!

You have successfully completed our first Arduino "How to" tutorial and you learned how to use:

  • led
  • constants
  • pinMode(), digitalWrite() and delay() functions

I hope you liked this, let me know in the comments.

There will be more of them, so make sure to click Follow button :)

Welcome to the Arduino world!

Comments

smandal13 (author)2015-08-15

great job

samuel123abc (author)2015-05-27

Greta instructable, thanks for sharing :)

MakerBox (author)2015-05-25

sorry to correct you but it is "how to make an led blink" no "a led" sorry but good 'ible ;)

samuel123abc (author)MakerBox2015-05-27

Correct, you use "an" before a vowel sound, so if you pronounce it "el - ee - dee" it should be "an".

Long story short - an LED

Samuel

krevok (author)MakerBox2015-05-25

*'able

MakerBox (author)krevok2015-05-26

i'ble

Saiyam (author)MakerBox2015-05-26

When you pronounce it as 'LED' it should be 'an LED' as you said correctly but if you pronounce it as 'light emitting diode' that is the full name, it should be 'a light emitting diode.'

combi1955 (author)MakerBox2015-05-25

'a led' sounds fine to me, why should that be 'an'

combi1955 (author)combi19552015-05-25

you are right, when you're right you're right.
but shouldn't it be 'an LED', seeing it's an acronym?

daemoncan (author)2015-05-26

Break into an electronics museum, steal an LM3909 and be done with it...... :)

seamster (author)2015-05-25

Nicely done. Thanks for sharing this!

About This Instructable

7,314views

139favorites

License:

Bio: Arduino Tutorials by Codebender.cc Team
More by codebender_cc:How to use a magnetic door switch / sensor with ArduinoHow to Measure LUX With ArduinoHow to Control an RGB LED Strip - Arduino Tutorial
Add instructable to: