From charlesreid1

Blink LED

Overview

In this article, we go over a simple blink program using the Arduino Micro. This is the same as the Hello World Arduino Micro circuit, but with the Arduino controlling the voltage of the circuit to make it blink.

In the simple Hello World example, we wanted a constant source of potential, 5 volts, to keep the LED light continuously lit. Now, we want to control the voltage so that we can shut the light on and off. The program we load onto the Arduino microcontroller will allow us to create a logical program to control the voltage.

The Circuit

Breadboard Diagram

The circuit for our blink program is almost exactly the same as for the Hello World program, except now we plug it into a numbered pin on the Arduino board:

Bb Blink1.png

Instead of plugging into the 5V pin, we plug it into the D12 pin.

NOTE: Don't use the D13 pin. It starts with a pulse on-off routine.

Breadboard Photo

The final breadboard arrangement:

Photo Blink1.jpg

Note that we've added three resistors, instead of two. It doesn't particularly matter - as long as the resistance is not too low! (Otherwise we'll burn out our LED.)

The Arduino Sketch Code

The following Arduino sketch will make the LED blink:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}


// this sends SOS forever

void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(200);
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(200);

Now, we can make the LED blink "SOS" with some very clunky code:

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}


// this sends SOS forever

void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(200);
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(200);
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);

  delay(1000);

  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(200);

  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(200);

  digitalWrite(13, HIGH);
  delay(500);
  digitalWrite(13, LOW);
  delay(200);

  delay(1000);

  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);

  delay(1000);

}

This works, for demonstrating how a blink circuit works, but it'd sure be nice to have a Morse Code library and make that code more compact and graceful.

Using a Morse Code Library

Here is a link to an article describing a blink circuit using a morse code library:

Morse Code Blink Arduino Micro


Flags