Homework 02 — Create an LED Arduino Code — Garrett Jensen

28 Oct

Using the San Jose Sharks goal horn and song I tried to match the lights to light at the same time at distinct moments.

The code I used is:

int blue = 3;
int green = 5;
int red = 6;

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

void loop() {
digitalWrite(red, HIGH); // turn red light on (goal horn)
delay(4000); // red light stays on for 4 seconds
digitalWrite(red, LOW); // turn red light off
delay(3000); // red light stays off for 3 seconds
digitalWrite(red, HIGH); // turn red light on (goal horn)
delay(3000); // red light stays on for 3 seconds
digitalWrite(red, LOW); // turn red light off
delay(11000); // red light stays off or 11 seconds (music)
digitalWrite(blue, HIGH); // turn blue light on
delay(1000); // blue light stays on for 1 second (“hey”)
digitalWrite(blue, LOW); // turn blue light off
delay(2000); // blue light stays off for 2 seconds
digitalWrite(blue, HIGH); // turn blue light on (“hey”)
delay(1000); // blue light stays on for 1 second
digitalWrite(blue, LOW); // turn blue light off
delay(3000); // blue light stays off for 3 seconds
digitalWrite(blue, HIGH); // turn blue light on (“hey”)
delay(1000); // blue light stays on for 1 second
digitalWrite(blue, LOW); // turn blue light off
delay(3000); // blue light stays off for 3 seconds
digitalWrite(red, HIGH); // turn red light on
delay(1000); // red light stays on for 1 second
digitalWrite(blue, HIGH); // turn blue light on
delay(1000); // blue light stays on for 1 second
digitalWrite(green, HIGH); // turn green light on
delay(1000); // green light stays on for 1 second
digitalWrite(red, LOW); // turn red light off
delay(10000); // red light stays off for 10 seconds
digitalWrite(green, LOW); // turn green light off
delay(10000); // green light stays off for 10 seconds
digitalWrite(blue, LOW); // turn blue light off
delay(10000); // blue light stays off for 10 seconds
}

Advertisements

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