Ardumotive Arduino Greek Playground
  • Home
    • About us
    • Contact
    • License
  • Arduino
    • Tutorials
    • Workshop
  • Raspberry Pi
  • DIY 3D Printer
  • News
    • Events >
      • Unboxing & Review
    • Blog
The 1st Arduino Playground in Greece - Open Source Hardware

Blink an LED

Available Languages
Picture
Picture

Introduction 

Picture
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!

Video in Greek language

What you will need - Hardware

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.

Picture

The Circuit

Picture
The connections are pretty easy, see the image above with breadboard circuit schematic.
Picture
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 code

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)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
/* Learn to use and blink an LED with Arduino - Tutorial
 * Info: http://www.ardumotive.com/how-to-blink-an-led-en.html
 * Dev: Michalis Vasilakis / Date: 19/10/2014  */

//Constants
const int ledPin = 3; 

void setup() {     
  //Initialize the digital pin as an output with pinMode()
  pinMode(ledPin, OUTPUT); 
}

void loop() {
  digitalWrite(ledPin, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(3000);                  // wait for 3 seconds
  digitalWrite(ledPin, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);                  // wait for 3 seconds
}
Download the code from here and open it with Arduino IDE.
blink_an_led.zip
File Size: 0 kb
File Type: zip
Download File

Now start making your own modifications to the code. For example you can add a second led or change the delay time.

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.
Welcome to the Arduino world!

Picture

Search Engine

Picture

Licence 

Picture

Help us to grow up!

Picture


Donate us
About us
License
Cookies policy

Visit the biggest Arduino Shop in Greece!

Picture
find us on dwrean.net
find us on Codebender
find us on Instructables
Developed and designed by Vasilakis Michalis Copyright © 2013 Ardumotive All Rights Reserved
All trademarks referenced herein are properties of their
Powered by Create your own unique website with customizable templates.
Design by DivTag Templates