Homework 02 — Create an LED Arduino Code — Alexa Zyllo

28 Oct

LED lights flash to the Christmas tune of  “Jingle Bells”

“Jingle bells, jingle bells, jingle all the way. Oh what fun it is to ride in a one horse open sleigh…hey!”

________________________________________________________________

Here’s the code:

int red = 3;      //setting red LED variable
int green = 5;      //setting green LED variable
int blue = 6;      // setting blue LED variable

void setup() {
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue,OUTPUT);
}

void loop() {
digitalWrite(red, HIGH);      // turn the red light on “JIN”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “GLE”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW); // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “BELLS”
delay(500);      // wait 0.50 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(500);     // wait 0.50 seconds

digitalWrite(red, HIGH);      // turn the red light on “JIN”
delay(250);       //wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “GLE”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “BELLS”
delay(500);      // wait 0.50 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(500);      // wait 0.50 seconds

delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “JIN”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the green light on “GLE”
delay(250);      // wait 0.25 seconds

digitalWrite(green, LOW);      // turn the green light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “ALL”
delay(500);      // wait 0.50 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the green light on “THE”
delay(100);      // wait 0.10 seconds

digitalWrite(green, LOW);      // turn the green light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the green light on “WAY”
delay(600);      // wait 0.60 seconds

digitalWrite(green, LOW);      // turn the green light off
delay(250);      //  wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “OH”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “WHAT”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “FUN”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “IT”
delay(250);      // wwait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “IS”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);     // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the green light on “TO”
delay(250);      // wait 0.25 seconds

digitalWrite(green, LOW);      // turn the green light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the green light on “RIDE”
delay(250);      // wait 50 ms

digitalWrite(green, LOW);      // turn the green light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the green light on “IN”
delay(100);      // wait 0.10 seconds

digitalWrite(green, LOW);      // turn the green light off
delay(200);      // wait 0.20 seconds

digitalWrite(green, HIGH);      // turn the green light on “A”
delay(200);      // wait 0.20 seconds

digitalWrite(green, LOW);      // turn the green light off
delay(200);      // wait 0.20 seconds

digitalWrite(red, HIGH);      // turn the red light on “ONE”
delay(200);      // wait 0.20 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(200);      // wait 0.20 seconds

digitalWrite(red, HIGH);      // turn the red light on “HORSE”
delay(250);       // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the red light on “OH”
delay(250);      // wait 0.25 seconds

digitalWrite(green, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(green, HIGH);      // turn the red light on “PEN”
delay(250);      // wait 0.25 seconds

digitalWrite(red, LOW);      // turn the red light off
delay(250);      // wait 0.25 seconds

digitalWrite(red, HIGH);      // turn the red light on “SLEIGH”
digitalWrite(green, HIGH);     // turn the green light on “SLEIGH”
delay(1200);      // wait 1.20 seconds

digitalWrite(red, LOW);      // turn the red light off
digitalWrite(green, LOW);      // turn the green light off

digitalWrite(blue, HIGH);      // turn the blue light on “HEY!”
delay(400);      // wait 0.40 seconds

digitalWrite(blue, LOW);      // turn the blue light off

delay(4000);      // wait 4.0 seconds and start loop again

}

Advertisements

One Response to “Homework 02 — Create an LED Arduino Code — Alexa Zyllo”

  1. justinberken October 29, 2013 at 11:07 pm #

    Nice use of the delay function. Timing seems just right.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s