06 March 2010

Task 10 - set LED blinking @maximum discernible rate



/*
* Project: blink4quick
* Author: Jane-Maree Howard
* Date: Tuesday 24/02/2010
* Platform: Arduino 18
* Purpose: To demonstrate variable blink times for the built-in LED
* Operation: Sets up input & output pins in setup() method;
* Declares pin definition variable
* Declares delayTime variable
* Defines loop() to perform LED blinking & delay operations
* The whole idea is to vary the delay time to the point where individual blinks
* can no longer be detected...
* The author reports that she can just detect a delay time of 14 milliseconds
*/

int ledPin = 13; // LED connected to digital pin 13
//int delayTime = 20; // LED blink time
//int delayTime = 15; //comment out unused delay times
int delayTime = 14; //comment out unused delay times
//int delayTime = 13; //comment out unused delay times
//int delayTime = 12; //comment out unused delay times
//int delayTime = 10; //saves rewriting variable errors

// The setup() method runs once, when the sketch starts
void setup()
{
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}//end setup()

// Loop turns pin13 (LED) on, waits briefly, turns LED off, waits one second;
// repeats endlessly while Arduino has power
void loop()
{
digitalWrite(ledPin, HIGH); // turn the LED on
delay(delayTime); // wait for 'delayTime' milliseconds
digitalWrite(ledPin, LOW); // turn the LED off
delay(delayTime); // wait for 'delayTime' milliseconds
}//end loop()

//Author can just see the delay time at 14 milliseconds

2 comments:

  1. Well, i'm getting the hang of this now

    To see only the listed tasks in Embedded Notices,
    click on the TASKS label below any one listed task

    ReplyDelete

  2. Note that near the line


    int delayTime = 14;


    there are other 'delayTime' lines commented out


    This saves a bit of tedious editing.
    I just chose several values via cut-&-paste
    & successively 'un-commented in' as it were
    each value (& commented out the rest) until
    i found the delay time at which
    i could barely distinguish individual LED flashes

    ReplyDelete