Arduino - micros () function


Advertisements

The micros() function returns the number of microseconds from the time, the Arduino board begins running the current program. This number overflows i.e. goes back to zero after approximately 70 minutes. On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds (i.e. the value returned is always a multiple of four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has a resolution of eight microseconds.

micros() function Syntax

micros () ;

This function returns number of microseconds since the program started (unsigned long)

Example

unsigned long time; void setup() { 
   Serial.begin(9600); 
} 

void loop() { 
   Serial.print("Time:");
   time = micros(); //prints time since program started
   Serial.println(time); // wait a second so as not to send massive amounts of data
   delay(1000); 
}
arduino_time.htm

Useful Video Courses


Video

Learn to Build Advanced Embedded Systems using Arduino

65 Lectures 6.5 hours

Amit Rana

Video

Learn Arduino using simple drag and drop Blocks

43 Lectures 3 hours

Amit Rana

Video

Design 3D Printed Enclosure for Arduino Boards Fusion 360

20 Lectures 2 hours

Ashraf Said

Video

ESP32 + Arduino Interfacing: A Step by Step Course

19 Lectures 1.5 hours

Ashraf Said

Video

Make PIC microcontroller based Arduino Development Board

11 Lectures 47 mins

Ashraf Said

Video

Arduino Vs Raspberry PI Vs PIC Microcontroller

9 Lectures 41 mins

Ashraf Said

Advertisements