Video

Homework 02 – Create an LED arduino code – Sarah Wolf

27 Oct

I tried to replicate the effects of police lights using the Arduino board and LEDs. This is the code I used:

int ledDelay = 50; // delay by 50ms
int redPin = 9;
int bluePin = 11;

void setup() {
pinMode(redPin, OUTPUT);
pinMode(bluePin, OUTPUT);

}

void loop() {

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, HIGH); // turn the red light on
delay(ledDelay); // wait 50 ms

digitalWrite(redPin, :LOW); // turn the red light off
delay(ledDelay); // wait 50 ms

delay(100); // delay midpoint by 100ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, HIGH); // turn the blue light on
delay(ledDelay); // wait 50 ms

digitalWrite(bluePin, LOW); // turn the blue light off
delay(ledDelay); // wait 50 ms

}

Advertisements

2 Responses to “Homework 02 – Create an LED arduino code – Sarah Wolf”

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

    This is great Sarah. Did you use pins “9” and “11” on purpose?

    • sarahjoyewolf October 31, 2013 at 3:23 pm #

      Not really! I figured that since pins 3,5,6,9,10, and 11 are all supposed to be basically the same on the arduino board, that any of those pins would be perfectly fine to use. I just picked them at random.

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