Assignment 2.2

Post date: Jun 23, 2010 10:16:25 PM

A more succinct way to do the bounce pattern in my previous code could probably have been done as follows, however I feel that the way I did it was both simpler to program / read, and less memory intensive.

Nevertheless:

void patternBounce(int repetitions, int intervalLength)

{

for(int i=0; i < repetitions; i++) {

for (int ledPin = 8; ledPin <= 12; ledPin++) // set up for loop

{

pinMode(ledPin, OUTPUT); // sets the digital pin as output

digitalWrite(ledPin, HIGH); // sets the LED-ledPin on

delay(intervalLength); // waits for the predetermined interval

digitalWrite(ledPin, LOW); // sets the LED-ledPin off

}

for (int ledPin = 13; ledPin >= 9; ledPin--) // set up for loop

{

pinMode(ledPin, OUTPUT); // sets the digital pin as output

digitalWrite(ledPin, HIGH); // sets the LED-ledPin on

delay(intervalLength); // waits for the predetermined interval

digitalWrite(ledPin, LOW); // sets the LED-ledPin off

}

}

}