LED blinking with variable delay

Assignment: Introduction to Arduino and Physical Computing

Collaborators:

I wrote a code that makes the LED blink with different delays from 0 to 1 second, in steps of 100 milliseconds. The delay is reset once it crosses the one second mark.

 

int ledPin = 13;      // LED connected to digital pin 13

int val = 0;

void setup()

{

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

}

 

void loop()

{

 

val = val + 100;

if(val>1000)

{

val = 0;

}

 

digitalWrite(ledPin, HIGH);

delay(val);

digitalWrite(ledPin, LOW);

delay(val);

}

Assignment