Questions tagged [millis]

Is a standard library function. It returns the number of milliseconds since the Arduino board began running the current program.

Filter by
Sorted by
Tagged with
109
votes
4answers
80k views

How can I handle the millis() rollover?

I need to read a sensor every five minutes, but since my sketch also has other tasks to do, I cannot just delay() between the readings. There is the Blink without delay tutorial suggesting I code ...
3
votes
4answers
14k views

Measuring Time Between Inputs

I'm trying to measure the amount of time that has passed between every time a reed switch mounted on a wheel is activated to calculate the speed of a bike in miles per hour and display it on two 7 ...
1
vote
4answers
1k views

need help for saving the millis function when arduino was rebooted

I have two questions want to ask I'm using Arduino Uno with 16*2 LCD Blue ( also I have temp. sensor and two motors also 3 limit switches) ,, my code is working good, but sometimes my lcd stop ...
5
votes
4answers
20k views

millis() function with a button press

I am trying to use the millis() function to turn on a pin for a specified interval then turn off and turn on a second pin. It is intended to power a relay and offer a visual cue to when the cycle is ...
2
votes
1answer
162 views

How to start a block of code after a certain time?

I'm using a ATMega328P-PU on a breadboard as an arduino. How do you start a code after say 20 seconds have elapsed since startup? Example code:- if(condition) { //Start sending morse code! } My ...
10
votes
3answers
11k views

arduino - millis()

Copied from the Arduino reference - millis() Tip: Note that the parameter for millis is an unsigned long, errors may be generated if a programmer tries to do math with other datatypes such as ...
-1
votes
3answers
890 views

Time based scheduling, NTP vs delay()

Without asking an open-ended question, i wish to find the best way (resourcefulness) to execute methods from an arduino based on time. in a nutshell, every 10 minutes i want functionA() to be called &...
5
votes
4answers
6k views

Is `millis()` affected by long ISRs?

I have a project that uses timers and interrupts frequently. A lot of CPU time is spent handling ISRs over an extended period of time. Would this affect code inside the main loop that relies on the ...
6
votes
3answers
5k views

Visual clock with millisecond display refresh rate

I need to create a millisecond capable visual clock - I will use the clock for visual frame synchronization of multiple cameras. I found this project but it seems to use a LED display that only has ...
9
votes
2answers
4k views

Does millis() conflict with the PWM pins associated with timer 0?

I've read that the millis() function uses the same timer as a couple of PWM pins. If you're using those PWM pins, will millis() still return the correct value?
1
vote
2answers
1k views

Arduino time(milli) and pressure sensor

I've succeeded to get an Arduino to work with a pressure sensor. What I want to do is when I put pressure on the sensor, after 5 minutes the led lights on. it starts over again if there's no ...
13
votes
3answers
5k views

Is it possible to find the time taken by millis?

The function millis would be running in the span of 100+ microseconds or less. Is there a reliable way to go about measuring the time taken by a single millis call? One approach that comes to mind is ...
17
votes
5answers
9k views

How do I get an accurate time?

I've made a clock using an Arduino, but the time seems to drift. I am aware of the rollover issue; the clock seems to drift by about 15 minutes over the course of a week. I'm using a custom PCB with ...

1 2 3
4