2022年2月5日 星期六

24hr min sec

 int sec;

int min;

int hr;

long start_time;

long hr_setup = 3600000;

long min_setup = 60000;

long sec_setup = 1000;

void setup()

 {

  Serial.begin(9600);

}


void loop()

 {

  start_time = millis();

  hr = start_time / hr_setup;

  min = (start_time % hr_setup) / min_setup;

  sec = ((start_time % hr_setup) % min_setup) / sec_setup;

  Serial.print(hr);

  Serial.print(":");

  Serial.print(min);

  Serial.print(":");

  Serial.println(sec);

}

沒有留言:

張貼留言

algorithm

 #include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv)  { for(int j=2;j<=100;j++)//j...