Lab 1 :: Blinking LED

Submitted by ajeeta on Mon, 02/04/2013 - 22:18
ajeeta's picture

 

Description

Initially, in class, I set up the circuit with 1 green LED, and edited the code to make the LED blink faster, with a 0.1 second flash-delay cycle.

I then re-created the circuit with two LEDs, green and blue, and changed the code to make the two LEDs blink with variable speed. (green with a 0.1 second flash-delay and blue with a 1.0 second flash-delay cycle).

 

Components Used

1- Arduino Uno

1- Breadboard

1- 220 Ω Resistor

1- Green LED

1- Blue LED

 

Code

/*

  Blink

  Turns on green LED on for 0.1 second, then off for 0.1 second, 

  then turns on blue LED on for 1 second, then off for 1 second, repeatedly.

 

  This example code is in the public domain.

 */

 

// Pins 12 and 13 have LED's connected on most Arduino boards.

// give them a name:

int green = 13;

int blue = 12;

 

// the setup routine runs once when you press reset:

void setup() {                

  // initialize the digital pin as an output.

  pinMode(green, OUTPUT);   

  pinMode(blue, OUTPUT);   

}

 

// the loop routine runs over and over again forever:

void loop() {

  digitalWrite(green, HIGH);  // turn the green LED on (HIGH is the voltage level)

  delay(100);                 // wait for 0.1 second

  digitalWrite(green, LOW);   // turn the green LED off by making the voltage LOW

  delay(100);                 // wait for 0.1 second

  digitalWrite(blue, HIGH);   // turn the blue LED on (HIGH is the voltage level)

  delay(1000);                // wait for a second

  digitalWrite(blue, LOW);    // turn the blue LED off by making the voltage LOW

  delay(1000);                // wait for a second

}

 

Blue LED
Green LED
0
Your rating: None
Drupal theme by Kiwi Themes.