#include <iostream>
#include <unistd.h> //required for usleep()
using namespace std;
int main(){
//usleep will pause the program in micro-seconds (1000000 micro-seconds is 1 second)
const int microToSeconds = 1000000;
const double delay1 = 2 * microToSeconds; //2 seconds
const double delay2 = 4.5 * microToSeconds; //4.5 seconds
cout<<"Delay 1 in progress... ("<<delay1/microToSeconds<<"s)"<<endl;
usleep(delay1);
cout<<" => Delay 1 is over"<<endl<<endl;
cout<<"Delay 2 in progress... ("<<delay2/microToSeconds<<"s)"<<endl;
usleep(delay2);
cout<<" => Delay 2 is over"<<endl<<endl;
return 0;
}
// Arduino delay
delay("time");
// Where "time" is the delay in milliseconds
Code Example |
---|
Cpp :: c++ usleep() |
Cpp :: maximum in vector |
Cpp :: c++ milliseconds |
Cpp :: c++ count bits |
Cpp :: c++ delete directory |
Cpp :: sfml delta time |
Cpp :: c++ custom comparator for elements in set |
Cpp :: cpp speed cin cout |
Cpp :: count a character in a string c++ |
Cpp :: eosio multi index clear |
Cpp :: rotation to vector2 godot |
Cpp :: Tech mahindra coding questions |
Cpp :: c++ how to generate a random number in a range |
Cpp :: map of vector of struct error |
Cpp :: C++ std::async wait is taking forever |
Cpp :: ue4 ftext to int |
Cpp :: assign a struct to another c++ |
Cpp :: how to sort a string in c++ |
Cpp :: newline in c++ |
Cpp :: if not defined c++ |
Cpp :: c++ random number generator uniform distribution |
Cpp :: add partition mysql |
Cpp :: setw in c++ |
Cpp :: convert decimal to binary c++ |
Cpp :: maximum value in map in c++ |
Cpp :: c++ lcm |
Cpp :: g++ optimization flags |
Cpp :: built in led |
Cpp :: c++ open all files in directory |
Cpp :: how to get length of a file in c++ |