Tutorial.Blink History

Show minor edits - Show changes to markup

May 02, 2012, at 03:34 AM by Scott Fitzgerald -
Changed line 55 from:
to:
November 16, 2011, at 12:21 AM by Scott Fitzgerald -
Changed line 55 from:
to:
September 30, 2011, at 02:55 AM by Scott Fitzgerald -
Changed line 55 from:
to:
February 06, 2011, at 02:54 PM by Tom Igoe -
Changed lines 15-16 from:

To build the circuit, get an LED and attach its long, positive leg (called the anode) to pin 13. Attach the short negative leg (called the cathode) to ground. Then plug your Arduino board into your computer, start the Arduino program, and enter the code below.

to:

To build the circuit, attach a 220-ohm resistor to pin 13. Then attach the long leg of an LED (the positive leg, called the anode) to the resistor. Attach the short leg (the negative leg, called the cathode) to ground. Then plug your Arduino board into your computer, start the Arduino program, and enter the code below.

Deleted lines 31-32:

If you've got experience with electronics, you may notice that the LED doesn't have a resistor in series with it. This is because the amount of current coming out of the output pin of the Arduino is low enough that it won't damage the LED. This simplifies the circuit for beginners to delete the resistor. In general practice, though, it's a good idea to add a resistor in series with the LED.

October 28, 2010, at 06:39 PM by Tom Igoe -
Changed lines 15-16 from:

To build the circuit, get an LED and attach its long, positive leg (called the anode) to pin 13. Attach the short negative leg (called the anode) to ground. Then plug your Arduino board into your computer, start the Arduino program, and enter the code below.

to:

To build the circuit, get an LED and attach its long, positive leg (called the anode) to pin 13. Attach the short negative leg (called the cathode) to ground. Then plug your Arduino board into your computer, start the Arduino program, and enter the code below.

September 23, 2010, at 10:01 PM by Christian Cerrito -
Added lines 21-22:

click the image to enlarge

Changed line 34 from:
to:

click the image to enlarge

September 17, 2010, at 05:16 PM by Tom Igoe -
September 17, 2010, at 05:08 PM by Tom Igoe -
Changed lines 66-69 from:
  • BareMinimum - bare minimum code needed to start a sketch
  • DigitalReadSerial - read a switch, print the state out to the Serial Monitor
  • AnalogReadSerial - read a potentiometer, print the state out to the Serial Monitor
  • Fade - fade an LED with analog output
to:
September 07, 2010, at 08:49 PM by Tom Igoe -
Changed lines 1-6 from:

Examples > Digital I/O

Blink

In most programming languages, the first program you write prints "hello world" to the screen. Since an Arduino board doesn't have a screen, we blink an LED instead.

to:

Examples > Basics

Blink

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

Deleted line 12:
Changed lines 15-18 from:

The boards are designed to make it easy to blink an LED using digital pin 13. Some (like the Diecimila and LilyPad) have the LED built-in to the board. On most others (like the Mini and BT), there is a 1 KB resistor on the pin, allowing you to connect an LED directly. (To connect an LED to another digital pin, you should use an external resistor.)

LEDs have polarity, which means they will only light up if you orient the legs properly. The long leg is typically positive, and should connect to pin 13. The short leg connects to GND; the bulb of the LED will also typically have a flat edge on this side. If the LED doesn't light up, trying reversing the legs (you won't hurt the LED if you plug it in backwards for a short period of time)

to:

To build the circuit, get an LED and attach its long, positive leg (called the anode) to pin 13. Attach the short negative leg (called the anode) to ground. Then plug your Arduino board into your computer, start the Arduino program, and enter the code below.

Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example with no hardware attached, you should see that LED blink.

Added lines 23-24:

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Changed lines 30-33 from:

click the image to enlarge

to:

If you've got experience with electronics, you may notice that the LED doesn't have a resistor in series with it. This is because the amount of current coming out of the output pin of the Arduino is low enough that it won't damage the LED. This simplifies the circuit for beginners to delete the resistor. In general practice, though, it's a good idea to add a resistor in series with the LED.

Changed lines 36-39 from:

Code

The example code is very simple, credits are to be found in the comments.

to:

Code

In the program below, the first thing you do is to initialize pin 13 as an output pin with the line

pinMode(13, OUTPUT);

In the main loop, you turn the LED on with the line:

digitalWrite(13, HIGH);

This supplies 5 volts to pin 13. That creates a voltage difference across the pins of the LED, and lights it up. Then you turn it off with the line:

digitalWrite(13, LOW);

That takes pin 13 back to 0 volts, and turns the LED off. In between the on and the off, you want enough time for a person to see the change, so the delay() commands tell the Arduino to do nothing for 1000 milliseconds, or one second. When you use the delay() command, nothing else happens for that amount of time. Once you've understood the basic examples, check out the BlinkWithoutDelay example to learn how to create a delay while doing other things.

Once you've understood this example, check out the DigitalReadSerial example to learn how read a switch connected to the Arduino.

Changed lines 55-57 from:
to:
Added lines 57-69:

See Also

August 24, 2010, at 09:01 PM by Christian Cerrito -
Changed line 26 from:

Schematic:

to:

Schematic

August 24, 2010, at 09:00 PM by Christian Cerrito -
Changed lines 14-15 from:

""Circuit""

to:

Circuit

August 24, 2010, at 09:00 PM by Christian Cerrito -
Added lines 7-15:
Changed lines 18-22 from:

LEDs have polarity, which means they will only light up if you orient the legs properly. The long leg is typically positive, and should connect to pin 13. The short leg connects to GND; the bulb of the LED will also typically have a flat edge on this side. If the LED doesn't light up, trying reversing the legs (you won't hurt the LED if you plug it in backwards for a short period of time).

""Circuit""

to:
Added lines 24-25:
Changed lines 27-28 from:
to:
Changed lines 33-35 from:

to:
August 24, 2010, at 08:52 PM by Christian Cerrito -
Changed lines 11-13 from:

Circuit

to:

""Circuit""

August 24, 2010, at 07:45 PM by Christian Cerrito -
Changed lines 13-14 from:
to:
August 15, 2010, at 08:35 PM by Tom Igoe -
Changed line 30 from:
to:
February 24, 2010, at 04:16 AM by Tom Igoe -
Changed line 30 from:
to:
February 24, 2010, at 04:16 AM by Tom Igoe -
Changed lines 30-49 from:
 /*
   Blink
  
  Turns on an LED on for one second, then off for one second, repeatedly.
  
  The circuit:
  * LED connected from digital pin 13 to ground.
  
  * Note: On most Arduino boards, there is already an LED on the board
  connected to pin 13, so you don't need any extra components for this example.
  
  
  Created 1 June 2005
  By David Cuartielles
  
  http://arduino.cc/en/Tutorial/Blink
  
  based on an orginal by H. Barragan for the Wiring i/o board
  
  */
to:
Changed lines 32-52 from:
to:
July 05, 2009, at 07:12 PM by Tom Igoe -
Changed line 71 from:
to:
July 05, 2009, at 07:07 PM by Tom Igoe -
Changed lines 28-30 from:

[@ /*

  Blink
to:
Changed line 51 from:
 Turns on an LED on for one second, then off for one second, repeatedly.
to:
 int ledPin =  13;    // LED connected to digital pin 13
Changed lines 53-54 from:
 The circuit:
 * LED connected from digital pin 13 to ground.
to:
 // The setup() method runs once, when the sketch starts
Changed lines 55-56 from:
 * Note: On most Arduino boards, there is already an LED on the board
 connected to pin 13, so you don't need any extra components for this example.
to:
 void setup()   {                
   // initialize the digital pin as an output:
   pinMode(ledPin, OUTPUT);     
 }
Added lines 60-61:
 // the loop() method runs over and over again,
 // as long as the Arduino has power
Changed lines 63-64 from:
 Created 1 June 2005
 By David Cuartielles
to:
 void loop()                     
 {
   digitalWrite(ledPin, HIGH);   // set the LED on
   delay(1000);                  // wait for a second
   digitalWrite(ledPin, LOW);    // set the LED off
   delay(1000);                  // wait for a second
 }
Changed lines 71-97 from:
 http://arduino.cc/en/Tutorial/Blink

 based on an orginal by H. Barragan for the Wiring i/o board

 */

int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts

void setup() {

  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);     

}

// the loop() method runs over and over again, // as long as the Arduino has power

void loop() {

  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(1000);                  // wait for a second

}

@]

to:
June 25, 2009, at 01:54 PM by Tom Igoe -
June 25, 2009, at 01:54 PM by Tom Igoe -
Changed lines 16-17 from:

[-click the image to enlarge-]

to:

click the image to enlarge

June 25, 2009, at 01:53 PM by Tom Igoe -
Changed lines 18-22 from:

to:

June 25, 2009, at 01:52 PM by Tom Igoe -
Changed lines 15-18 from:

Schematic

to:

Schematic: [-click the image to enlarge-]

June 25, 2009, at 01:50 PM by Tom Igoe -
Added lines 15-18:

Schematic

June 25, 2009, at 11:27 AM by Tom Igoe -
Changed lines 33-34 from:
 By DojoDave <http://www.0j0.org>
 http://arduino.berlios.de
to:
 By David Cuartielles
Added lines 35-36:
 http://arduino.cc/en/Tutorial/Blink
June 17, 2009, at 11:13 PM by Tom Igoe -
Changed lines 20-32 from:

/* Blinking LED

 * ------------
 *
 * turns on and off a light emitting diode(LED) connected to a digital  
 * pin, in intervals of 2 seconds. Ideally we use pin 13 on the Arduino 
 * board because it has a resistor attached to it, needing only an LED

 *
 * Created 1 June 2005
 * copyleft 2005 DojoDave <http://www.0j0.org>
 * http://arduino.berlios.de
 *
 * based on an orginal by H. Barragan for the Wiring i/o board
to:

/*

  Blink

 Turns on an LED on for one second, then off for one second, repeatedly.

 The circuit:
 * LED connected from digital pin 13 to ground.

 * Note: On most Arduino boards, there is already an LED on the board
 connected to pin 13, so you don't need any extra components for this example.

 Created 1 June 2005
 By DojoDave <http://www.0j0.org>
 http://arduino.berlios.de

 based on an orginal by H. Barragan for the Wiring i/o board
Changed lines 40-44 from:

int ledPin = 13; // LED connected to digital pin 13

void setup() {

  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
to:

int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts

void setup() {

  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);     
Changed lines 49-52 from:

void loop()

to:

// the loop() method runs over and over again, // as long as the Arduino has power

void loop()

Changed lines 54-57 from:
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
to:
  digitalWrite(ledPin, HIGH);   // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delay(1000);                  // wait for a second
Added line 59:
February 15, 2008, at 11:59 PM by David A. Mellis - clarifying that some boards have built-in leds, others have 1 KB resistor on pin 13
Changed lines 5-10 from:

The first program every programmer learns consists in writing enough code to make their code show the sentence "Hello World!" on a screen.

As a microcontroller, Arduino doesn't have any pre-established output devices. Willing to provide newcomers with some help while debugging programs, we propose the use of one of the board's pins plugging a LED that we will make blink indicating the right functionallity of the program.

We have added a 1K resistor to pin 13, what allows the immediate connection of a LED between that pin and ground.

to:

In most programming languages, the first program you write prints "hello world" to the screen. Since an Arduino board doesn't have a screen, we blink an LED instead.

The boards are designed to make it easy to blink an LED using digital pin 13. Some (like the Diecimila and LilyPad) have the LED built-in to the board. On most others (like the Mini and BT), there is a 1 KB resistor on the pin, allowing you to connect an LED directly. (To connect an LED to another digital pin, you should use an external resistor.)

February 03, 2007, at 03:32 PM by David A. Mellis -
Changed lines 3-4 from:

Blinking LED

to:

Blink

February 03, 2007, at 10:51 AM by David A. Mellis -
Changed lines 3-4 from:

blink

to:

Blinking LED

February 03, 2007, at 10:51 AM by David A. Mellis -
Changed lines 3-4 from:

Blinking LED

to:

blink

January 29, 2007, at 06:39 PM by David A. Mellis -
Changed lines 3-4 from:

Blink

to:

Blinking LED

January 28, 2007, at 12:06 PM by David A. Mellis -
Changed lines 3-4 from:

blink

to:

Blink

Added lines 13-14:

Circuit

Changed lines 17-18 from:

Code

to:

Code

January 28, 2007, at 11:27 AM by David A. Mellis -
Changed line 21 from:
 * -----------
to:
 * ------------
January 28, 2007, at 11:27 AM by David A. Mellis -
Changed line 21 from:
 * ------------
to:
 * -----------
Deleted line 43:
  if (1 & 0) 
January 28, 2007, at 11:27 AM by David A. Mellis -
Changed line 44 from:
  if (1 < 0) 
to:
  if (1 & 0) 
January 28, 2007, at 11:26 AM by David A. Mellis -
Changed line 19 from:

[=

to:

[@

Added line 44:
  if (1 < 0) 
Changed line 50 from:

=]

to:

@]

January 28, 2007, at 11:26 AM by David A. Mellis -
Changed lines 15-19 from:

[@ // blink // <http://www.arduino.cc/en/Tutorial/Blink> int pin = 13;

to:

Code

The example code is very simple, credits are to be found in the comments.

[= /* Blinking LED

 * ------------
 *
 * turns on and off a light emitting diode(LED) connected to a digital  
 * pin, in intervals of 2 seconds. Ideally we use pin 13 on the Arduino 
 * board because it has a resistor attached to it, needing only an LED

 *
 * Created 1 June 2005
 * copyleft 2005 DojoDave <http://www.0j0.org>
 * http://arduino.berlios.de
 *
 * based on an orginal by H. Barragan for the Wiring i/o board
 */

int ledPin = 13; // LED connected to digital pin 13

Changed line 39 from:
  pinMode(pin, OUTPUT);
to:
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
Changed lines 44-47 from:
  digitalWrite(pin, HIGH);
  delay(1000);
  digitalWrite(pin, LOW);
  delay(1000);
to:
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(1000);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(1000);                  // waits for a second
Changed line 49 from:

@]

to:

=]

January 28, 2007, at 11:25 AM by David A. Mellis -
Changed lines 5-6 from:

This example blinks the LED on pin 13, turning it on for one second, then off for one second, and so on.

to:

The first program every programmer learns consists in writing enough code to make their code show the sentence "Hello World!" on a screen.

As a microcontroller, Arduino doesn't have any pre-established output devices. Willing to provide newcomers with some help while debugging programs, we propose the use of one of the board's pins plugging a LED that we will make blink indicating the right functionallity of the program.

We have added a 1K resistor to pin 13, what allows the immediate connection of a LED between that pin and ground.

LEDs have polarity, which means they will only light up if you orient the legs properly. The long leg is typically positive, and should connect to pin 13. The short leg connects to GND; the bulb of the LED will also typically have a flat edge on this side. If the LED doesn't light up, trying reversing the legs (you won't hurt the LED if you plug it in backwards for a short period of time).

January 28, 2007, at 11:14 AM by David A. Mellis -
Changed lines 1-2 from:

Examples > Digital I/O

to:

Examples > Digital I/O

Added lines 8-9:

// blink // <http://www.arduino.cc/en/Tutorial/Blink>

January 28, 2007, at 11:03 AM by David A. Mellis -
Changed lines 1-2 from:

Examples > Digital I/O > blink

to:

Examples > Digital I/O

blink

January 28, 2007, at 11:03 AM by David A. Mellis -
Changed lines 1-2 from:

examples > digital > blink

to:

Examples > Digital I/O > blink

January 28, 2007, at 11:02 AM by David A. Mellis -
Added lines 1-4:

examples > digital > blink

This example blinks the LED on pin 13, turning it on for one second, then off for one second, and so on.

January 14, 2007, at 03:24 PM by David A. Mellis -
Added lines 1-16:
int pin = 13;

void setup()
{
  pinMode(pin, OUTPUT);
}

void loop()
{
  digitalWrite(pin, HIGH);
  delay(1000);
  digitalWrite(pin, LOW);
  delay(1000);
}

Share