Arduino Programming Language: Delay

Name

delay()

Description

This function pauses the program for a specified amount of time, expressex in milliseconds.

Syntax

delay(milliseconds);

Parameters

  • milliseconds: unsigned long containind the amount of time to delay the program

Returns

none 

Usage

Application

Examples

// The blink sketch well explain the delay function
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}

void loop()
{
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
}

Related Functions


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc