Skip to main content

Time

Time

This library waits for and/or measures the specified time.

millis

Description

Returns the number of milliseconds since the GR-COTTON board began running the current program.

Syntax

unsigned long millis()

Parameters

None

Returns

Number of milliseconds since the program started (unsigned long)

micros

Description

Returns the number of microseconds since the GR-COTTON board began running the current program.

Syntax

unsigned long micros()

Parameters

None

Returns

Number of microseconds since the program started (unsigned long)

delay

Description

Pauses the program for the amount of time (in milliseconds) specified as parameter.

Syntax

delay(unsigned long ms)

Parameters

ms: The number of milliseconds to pause

Returns

None

delayMicroseconds

Description

Pauses the program for the amount of time (in microseconds) specified as parameter.

Syntax

delayMicroseconds(unsigned long us)

Parameters

us: The number of microseconds to pause

Returns

None


Sample Program

Displays the time since program start in 100ms intervals via serial communications.


        #include <Arduino.h>
        #define INTERVAL 100
        unsigned long val_time;
            
        void setup()
        {
            Serial.begin(9600);
        }
            
        void loop()
        {
            val_time = millis();
            Serial.println( val_time );
            delay(INTERVAL);
        }