Tracking timeDelay

Arduino



This time we will shortly timeDelay tracking and sends a message to the computer that the LED is turn on or off. LED we will use for the experiment is the existing LED on the Arduino board is connected to pin 13, note the LED labeled "L" on the Arduino board.

Sketch 1 Program tracking timeDelay


// Free Tutorial Arduino
// www.ioisalman.com


const int LED = 13;
timeDelay int = 3000;

void setup () {
   Serial.begin (9600);
  
   Serial.println ("pin 13 as OUTPUT");
   pinMode (LED, OUTPUT);

Serial.println ("LED = ON, during timeDelay = 3 seconds");
   digitalWrite (LED, HIGH);
   delay (timeDelay);
}

void loop () {
   if (timeDelay <= 100) {
     Serial.println ("Reset timeDelay to 1000");
     timeDelay = 1000;
   }
  
   Serial.println ();
   Serial.print ("timeDelay =");
   Serial.println (timeDelay);
  
   Serial.println ("LED = OFF");
   digitalWrite (LED, LOW);
   delay (timeDelay);
   Serial.println ("LED = ON");
   digitalWrite (LED, HIGH);
   delay (timeDelay);
  
   timeDelay = timeDelay - 100;
}

Program on Sketch 1 is a simple example for debugging, it means we want to know what the program by knowing each variable and how the behavior of the program. At least one program on the Sketch have an output like the following:


pin 13 as OUTPUT
LED = ON, during timeDelay = 3 seconds

timeDelay = 3000
LED = OFF
LED = ON

timeDelay = 2900
LED = OFF
LED = ON

timeDelay = 2800
LED = OFF
LED = ON

etc. ...


Subscribe to receive free email updates:

0 Response to "Tracking timeDelay "

Post a Comment