How may millis and micro

how many millis and micros can be used , 2 8bit timer and 1 16 bit timer is suited for which Millis and micros . using the millis and micros will affect the pwm ? .

Using millis() or micros() will not affect PWM output

On the Arduino UNO and Nano, the millis() and micros() functions use Timer0, one of the 8-bit timers.

Yes, and using Timer 0 for PWM will affect millis() and micros(), therefore...

Only if you muck with the hardware timer registers and don't just use analogWrite() for PWM.

hi, by default 1 millis or 1 micros is equal to approximately how many Millie or micro second .
millis or micros value based on the crystal value with +/- error ? .

it's possible to change the Millis or micros value ?

  • millis() returns the number of milliseconds since the Arduino was started or reset
  • micros() returns the number of microseconds since the Arduino was started or reset

I believe that it is possible to reset both but why would you want to ?

i aim use micros for every 1 second i need to check A/D convertor value . i guess 1000 micros() = 1 second . after the 2 minute i will rest unsigned long sec =micros() . from this cycle i can have 120 adc reading . you can suggest some simplified way .

Save the value of micros() when you check the A/D converter as the start time then each time through loop() do

currentMicros = micros();
if (currentMicros - startMicros > requiredPeriod)
  //read the A/D converter
  startMicros = currentMicros;

This method will not be affected by the micros() rollover if the timing variables are declared as unsigned longs

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.