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
1
vote
1answer
46 views

Atmega Millis with Quartz crystal

I followed https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard this tutorial to program my Atmega 328p to run on a breadboard with a 16 MHZ Quarz crystal and two 22pF capacitor. I want to program a ...
1
vote
2answers
472 views

Using millis() to create a timed sequence of events

I was hoping anyone could help me with my problem. I am trying to play a sequence of tones without using delay. So I am relying on millis(). However I have not been successful yet and after reading ...
1
vote
1answer
66 views

I need to change this code to start the section of code when the switch is on and not when the switch is released

I have this section of code. It works fine and how I want it only, it executes when the button is released not when it is pressed. My application needs to execute this code when a switch is on. The ...
1
vote
0answers
317 views

Stepper wait for X seconds in a loop with millis (not delay)

In the code below I would like the stepper to bounce back and forward between two limit switches and while it is doing this it should turn and than wait for e.g. 1 second. I thought I could achieve ...
1
vote
1answer
42 views

Elapsedtime variable not resetting

I am new to Arduino programming. Let me describe the application I am working on. I am pressing a button for a certain period of time (30 sec). I can not hold it in a pressed position for all the time....
1
vote
1answer
1k views

Measuring distance based on time [closed]

I have written a arduino sketch which is used to measure the distance travelled. Since distance = speed * time , I have initiated speed = 6. I have initiated time = millis() variable and it calculates ...
1
vote
1answer
318 views

Calculating with millis()

The following code works fine until I turn the if (tijd - action >= 500) into if (tijd - action >= 1000) I wonder why this fails. If I just loop and print the tijd - action it has no problem ...
1
vote
1answer
1k views

Help me restructure code for multitasking Neopixel + IR remote + arduino

First of all, I'm completely new to both arduino, and programing. Second, as for a good newbie, i'm trying to build a fairly complicated project. So, any help and suggestion is welcome. The goal is: ...
0
votes
3answers
521 views

Why doesn't millis() use 1 µsec or 1 msec interrupt?

Arduino millis() does not make use of one millisecond interrupt. Instead they make use of 1,024 µsec interrupts and manipulate. Any specific reason why this was implemented this way? In one case, we ...
0
votes
2answers
678 views

Does delay() pause the counting of millis()?

If I add a delay for a few seconds, and then will the value given by millis () be equal just before and after delay? Or to put it in other words, does the internal clock of Arduino stop during delay?
0
votes
2answers
76 views

Display upTime using `millis()` - Arduino Uno

I want to use the following function to display MCU's uptime, but after several hours I get error. void uptime(char *ret_clk) { byte days = 0; byte hours = 0; byte minutes = 0; byte seconds = ...
0
votes
2answers
81 views

Issue with simple project

I'm new to Arduino and today I have a problem with this code: int led_1 = 10; int led_2 = 11; int led_3 = 12; int button = 3; int time = 0; byte val = 0; void setup() { // put your setup code here,...
0
votes
1answer
156 views

to measure the time between the ON signal and OFF signal

int pin_state = LOW; struct Channel { byte pin; byte state; byte count; unsigned long fell, rose; }; const int CHANNEL_COUNT = 3; Channel channels[CHANNEL_COUNT] = ...
0
votes
3answers
817 views

Time.h rollover after 49.7 days [duplicate]

I'm developing a arduino based system, which includes a alarm system. Searching on the Internet, I found these lybraries "Time.h" and "TimeAlarms.h". In the requirements, it says: "Time does not ...
0
votes
1answer
721 views

Faster and lighter approximate timing code without using timer

I want to use loop() iterations counter to execute some tasks periodically or tasks like debouncing. My other sketch is running every loop() at least 20 ms, and if i am using 5 ms time to wait to ...
0
votes
3answers
1k views

millis() function always returns same value

I'm trying to program an Arduino MKR1000 and I am using the millis() function to emulate a traditional timer. The problem is that any call to millis() inside the debounceTimer() function returns the ...
0
votes
1answer
42 views

Why does my servo execute an action in the beginning when the odds are almost 0?

I made a servo motor turn if the result of random(0, 10000) is less than or equal to 1. If that is the case, the motor turns to 130 degrees, to 50 degrees, and then to default position(90 degrees). It ...
0
votes
1answer
43 views

Using millis() in unsynchronized manner

I am assuming millis() is a Timer ISR function. If so : When using millis() as mentioned in Arduino Reference : unsigned long currentMillis = millis(); What would happen if the ISR asynchronously ...
0
votes
1answer
335 views

How to reset millis( )?

I am currently doing a school project. There you have to program a stopwatch with the Arduino. I wrote a program where millis starts. But when I press my start button, millis don‘t start from 0. ...
0
votes
1answer
53 views

Detecting the down time of a system by subtracting the time when the sytem gives ON signal and when it goes OFF

int pin_state = LOW; struct Channel { byte pin; byte state; byte count; unsigned long fell, rose; // times of fall and rise }; const int CHANNEL_COUNT = 3; Channel ...
0
votes
2answers
379 views

Hold all "millis()" values in an array?

I'm working on a project where I could have up to six devices connected to an arduino, it might be the case that not all of them will be attached at the same time, and all of them need to be able to ...
0
votes
3answers
168 views

Millis...alternate flash

I thought I had the Millis() command sorted but i'm stumped on the one. Aim is to get 2 led's alternately dimming, they work great with delay(); of course....but i can't figure where i'm going wrong ...
0
votes
2answers
538 views

What am I doing wrong with my millis()?

Im new to Arduino and have been trying to use the millis() function for an assignment of mine. I have had a lot of trouble trying to get the millis() function to work but now it seems to be working ...
0
votes
1answer
1k views

Change from using the external crystal to the internal oscillator

BACKGROUND I have made my own Arduino PCB based on the circuit of the Arduino Pro Mini (below) (including the external oscillator). I have already written the firmware and the code is stable. The ...
0
votes
1answer
803 views

How to delay outside loop

I am using a function outside loop(), which is called after an interrupt. Inside this function, I am setting several relays that need to change after a second or two, depending on my setting. I tried ...
0
votes
1answer
115 views

Arduino Blocks at Uploading

I am trying to make an operating hours counter with arduino, i started with a basic script to make the arduino work as a stop watch, This is my script: unsigned long start=0, finish=0, elapsed=0; ...
0
votes
2answers
84 views

How to call multiple delayed functions using a single millis()

I am working in a project where I need to call more than 1 functions actually 4 functions using a single millis() Here is the code below. unsigned long then = 0; void loop(){ unsigned ...
0
votes
1answer
67 views

Arduino stuck in PT_WAIT_UNTIL

I am using the Protothread Library from Adam Dunkels. It is supposed to wait 1 second and then continue. But instead it gets stuck there and everything after that line is not executed. lastTimeBlink = ...
0
votes
1answer
73 views

how to ignore a sensor being tripped the first time and start recording millis on the 2nd time it is tripped

I am building a timing system that has a start, split and finish beams with this I am using a start gate that will drop when the race starts. when it drops it will trip the 1st sensor starting to ...
0
votes
2answers
783 views

How to keep track of millis during sleep mode

In my application, I need to keep track of the time the application has been running as well as use sleep modes. However, when using the sleep modes, Timer0 is disabled, and therefore millis stop ...
0
votes
3answers
63 views

restart counter of elapsed millis willingly with read

When I trigger high it will count for as long as I ask it while I am high then shut off. I am able to start counting again whenever I want by triggering low and going back to high and it starts from ...
0
votes
2answers
197 views

Restart sequence of NeoPixel stick with a push button at any time

I am really happy with my new Arduino stuff and playing around with all those pixels :). I am new to programming and it's difficult to understand it, but with every success, I grow in knowledge. My ...
0
votes
1answer
318 views

How do I put timers by using millis on 3 PIR sensors?

I want to make the PIRs to stay on for about 1 minute. I've found the code that can do so for 1 PIR, but I dont know how to apply the code for 3 PIRs. Here is the code for 1 PIR with timer using ...
0
votes
1answer
41 views

How to execute commands over desired amount of time

I have a program that receives 4 commands on 4 channels to change the color of an LED using mqtt communication. Lets just focus on two of the channels, the time and the red. I am sending a length of ...
0
votes
1answer
209 views

millis() function works with inline code and gives output but when creating own library it doesn't works

I am creating library for GPS to use in my project. I am using Adafruit GPS and its library to create my own library in which I am using millis() function to display the GPS Location after 1 minute (...
0
votes
1answer
101 views

Arduino stops logging data after ~32761 seconds

I made a small set up to log temperature on SD card, everything is running smoothly until it reach 9:06:01 of logging that is 32761 seconds. I know that corresponds roughly to the maximum value of an ...
0
votes
1answer
193 views

Regarding running multiple functions using millis

I have been writing code for measuring when the digital signal comes and goes (ON and OFF respectively). I have done the part calculating a single system's downtime (difference in timings between ON ...
0
votes
1answer
41 views

Button that gives an Input, Has a small delay --- then gives another [closed]

I'm pretty new to the Arduino scene, and my question will likely be solved simply by some more experienced fellows. I'm trying to create a code for a switch/ button that when you press it, it ...
0
votes
1answer
659 views

Function Millis() Arduino

I would like to make a countdown with arduino. To do this I'm using the millis () function, but I have a problem, I can not reset this. Reading on the internet I read that it is not possible to do ...
0
votes
1answer
1k views

LED Strip Effect without delay

so a brief introduction about the project which I am working on before I go onto my issue. I am working on a love-o-meter project (Not similar to the arduino example), whereby 2 people place 1 of ...
0
votes
1answer
121 views

Using time function in arduino

how to get exact timestamp of a sensor reading and compare it with other sensor values in arduino? Ex: Get the time of low reading of LDR and compare it
0
votes
1answer
185 views

How to replace the delay() function in my code?

I'm new to Arduino and I currently have a project that involves the control of an LED via ultrasonic sensor. Basically, if an object passes through the ultrasonic sensor, the LED will be ON for 5 ...
0
votes
1answer
2k views

Using millis() to time the start / stop of a DC motor

I'm trying to use a DC motor with pinion engaged to a rack gear, and have that motor move a distance, save the distance, delay, reverse, and travel back the same distance from where it started, delay, ...
0
votes
1answer
304 views

What is wrong with my state machines?

My goal is to make an automatic gate and garage door, and it has a servo as the lock mechanism on the gate, and alarm systems that notify when the gate or garage door is open too long, more than the ...
0
votes
1answer
662 views

Countdown sometime stop

I've made a game with 3 countdowns and 1 global countdown. When we start, the global one, go from 45:00 to 00:00. The 1 go from 15:00 to 00:00 and if it reach 00:00: The 2 start and go from 15:00 to ...
0
votes
2answers
746 views

Press on pressure sensor once, turn on LED for 6 seconds

I am working on a project where I would like to press on a pressure sensor (0-1024) once and turn on the LED and turn off by itself after 6 seconds. I am quite new to arduino and I can't seem to ...
0
votes
1answer
902 views

Using millis() function to start at potentiometer reading

I am trying to use the millis() function to start a countdown of 3 seconds when I turn my potentiometer to high travel. My code so far starts the timer at the beginning of the loop or when reset is ...
0
votes
2answers
171 views

Sketch does not work without delay() or other complex functions like digitalWrite()

I have a simple sketch here that should just blink a led once a second or so (approximately): boolean onOff=true; int count=0; void setup() { pinMode(13, OUTPUT); } void loop() { count++; ...
0
votes
1answer
965 views

ATtiny44 millis() not working with 16 MHz external clock

I'm using ATtiny44 with Arduino IDE according to this tutorial: http://highlowtech.org/?p=1695 I have a problem with millis(). When I use an internal 1 MHz clock it works correctly but when I use ...
0
votes
2answers
360 views

How do I set the motor state to "HIGH" at the beginning of this sketch?

My intent with this sketch is to have motors run for one minute, then stand by for 18 minutes. In practice, the sketch starts the motor state at "low" for the OffTime interval, then goes to the OnTime ...