The purpose of this lab was to:
Initial Code:
int ledPin = 13; // LED connected to digital pin 13 void setup() // run once, when the sketch starts { pinMode(ledPin, OUTPUT); // sets the digital pin as output } void loop() // run over and over again { digitalWrite(ledPin, HIGH); // sets the LED on delay(1000); // waits for a second digitalWrite(ledPin, LOW); // sets the LED off delay(1000); // waits for a second }
Modified Code:
I just tinkered with the code a little bit to make the delay time twice as long for each iteration of the loop. Each time the LED blinked, it lasted twice as long and turned off for twice as long than the time before:
int ledPin = 13; // LED connected to digital pin 13 int delayTime = 1; // **Initial delay time void setup() // run once, when the sketch starts { pinMode(ledPin, OUTPUT); // sets the digital pin as output } void loop() // run over and over again { digitalWrite(ledPin, HIGH); // sets the LED on delay(delayTime); // "on" for "delayTime" amount of time. digitalWrite(ledPin, LOW); // sets the LED off delay(delayTime); // "off" for "delayTime" amount of time. delayTime = delayTime*2; // double the delay time. }