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
41 views

Blink LED with different on off times just once with millis

So Im having trouble trying to figure this out. My project needs a valve to stay shut and when an event is triggered, 3 seconds into that event the valve opens for 2 seconds, then remain shut till it'...
0
votes
2answers
40 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
41 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
38 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 ...
1
vote
1answer
43 views

How to use millis instead of delay? [duplicate]

Sorry if something similar has been answered before... I am working on a garden timer project that runs on a ESP8266 based NodeMCU and is integrated with Blynk. I have a waterNow function that ...
1
vote
1answer
70 views

Millis timer question

Trying to figure out how to do this in millis. So right now the code works just fine, plays mp3_play(2) while a push button is closed then plays mp3_play(1) when its open. Lets say I want mp3_play(2) ...
1
vote
1answer
33 views

Get production count for current minute

I am trying to make a production counter for a machine. I want to display production count of the last minute for each seconds. So, display should update every second and should display real value of ...
0
votes
1answer
70 views

ESP32 millis not working properly

I have a program which measures temperatures every 30 minutes and sends them to a database. Immediately after running the program the first measurement is sent, however, the second (which should be ...
1
vote
2answers
71 views

Using millis() instead of delay() when playing a melody

I want to make my Arduino to play several simple melodies, and also be able to skip a melody by pressing a button and go on with the next song. therefore I cannot use delay() because the code should ...
1
vote
1answer
26 views

How can I remove the delays in this code for sweeping the servo?

I know this is probably a very asked question, but I am building a fairly basic radar type thing which sweeps left and right and uses an ultrasonic sensor to determine the distance to an object and a ...
1
vote
0answers
74 views

Arduino interface of push button and led using millis()

I am working on a project of blinking of led using push button without delay().The limitations of led blinking is in accordance with the no of times the push button is pressed the led should blink ...
1
vote
1answer
32 views

Issue with simple timer based on millis()

Sorry to bother but I am at my wits end. I'm experimenting with timers, and starting very simple. The following code is supposed to print the content of a variable each time an interval of time has ...
1
vote
2answers
265 views

Switch on the piezo emitter for a short time

I need a short beep for every minute of change. I wrote a separate function. The signal duration should be 50 ms, the rest of the time the emitter connected to the A1 contact should be silent. A ...
1
vote
0answers
24 views

error ph meter cant show the data [duplicate]

im using ph meter DFROBOT v1.0 at i compiled the code from the DFROBOT web this is the code * # This sample code is used to test the pH meter V1.0. # Editor : YouYou # Ver : 1.0 # Product: ...
1
vote
1answer
44 views

Timing push button code

I am trying to time how long button is held for. The code seems to work but with two problems: the millis values are being read wrongly. If you hold the button for 1 second, it returns holdTime of ...
2
votes
2answers
155 views

smooth DC motor control with millis

So the task is to control 12v DC motor. With first button, you can add up motor speed by certain speed step. With second button, you can slow down motors speed by certain speed step. With third button ...
0
votes
1answer
58 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
0answers
44 views

How to get delay after millis and stop the relay

thats my flowchart for my code void loop() { //-------------Fungsi Read sensor----------- sensorAll(); hasilec = (ppmcensor - inputec); ph = (phcensor - inputph); // hasilec = random(...
2
votes
1answer
53 views

Relays just switch ON and OFF on delay(), not on millis()

I use fuzzy logic for the running time of relays, but the relays just switch ON and OFF at the interval of the delay() I put at the end of loop. This is my code: void loop () { ph = -180/100.0; ...
1
vote
3answers
122 views

Ignoring the first high output from the sensor

If the vibration sensor with Arduino detects two high inputs within 1 minute, I want the led to flash in one second. My ability to write Arduino code is very low; I tried with millis() but I couldn't. ...
3
votes
0answers
76 views

Help with millis to get accurate timing

I'm essentially trying to create a music box which is light activated using an LDR. When it's open a song plays, while a servo rotates a figurine back and forth, and an LED dims and illuminates in ...
1
vote
0answers
28 views

how to control 2 sensor and 3 relay with fuzzy

i'm using fuzzy to decide how long the relay on pump on and i got some trouble for it he just looping on relay how should i do thats my code //---------Fuzzy 2.1 prelauch---------- //-----iNPUT ...
1
vote
2answers
113 views

controlling 2 sensor and 3 pump using millis

i make a 3 pump for output and im using millis for it, i want to stop if rach the intervalm now in my code its still looping not realy stop for it thx int pump1 = 5;//pin D5 int pump2 = 6;//pin D6 int ...
2
votes
3answers
100 views

How to use millis() in my code instead of delay()?

I'm having issues trying to convert my code to non-blocking. I was able to do so in some parts, but the rest aren't the same. When I try to replace delay with an if statement like the spinning and ...
3
votes
2answers
247 views

How to use Multipile millis()

I've a exhaust fan that runs when the humidity is high. When the exhaust fan is on it should work for 3 minutes and should wait another 5 minutes to on. I am a beginner to this struggling for almost 2 ...
0
votes
0answers
49 views

IR Remote Breathing effect

Hı everyone I am trying give my led a breathing effect using millis() But neither led isnt breathinng and it stucks I cannot use other fucntions. Please help... #include <IRremote.h> #define ...
0
votes
0answers
22 views

Change delay function to millis function to play music2 [duplicate]

I'd like to write a code by changing the delay function in the music playing code to the millis function, do you know how? #define NOTE_B0 31 #define NOTE_C1 33 #define NOTE_CS1 35 #define NOTE_D1 ...
1
vote
0answers
102 views

Change delay function to millis function to play music

I'd like to write a code by changing the delay function in the music playing code to the millis function, do you know how? #include "pitches.h" // notes in the melody: int melody[] = { ...
0
votes
1answer
61 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
0answers
122 views

Run a dc motor for amount of time without delay

Hi everyone I have a project and I need to run a dc motor for amount of time without using delay I use DelayWithoutBlink technique. In this code the motor should run for 5 second in cw then it will ...
1
vote
2answers
96 views

Running Arduino with 2 outputs and 2 inputs

Totally new to Arduino, 3 weeks old! I am doing a project with 2 inputs (2 x ultrasonic sensors) and 2 outputs (buzzer and send SMS) The code to run the buzzer and sms works perfectly individually. ...
1
vote
1answer
56 views

3 input (on/off/off with delay) to control 1device using ESP8266 as Web Server

I want to control one device in three ways : turn on / turn off / turn off with delay. To do that i use an ESP8266 web server + android phone app. The problem is that turn off with delay wont work. It ...
0
votes
2answers
532 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 ...
1
vote
1answer
40 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 ...
0
votes
3answers
60 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
149 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
261 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 ...
2
votes
1answer
208 views

Can't use millis() instead of delay

I am making a home coming/leaving light for car. First I want that whenever I press the car key lock, a timer will start for 10 seconds. And if I press a button twice within 10 seconds, pin 13 will ...
-1
votes
2answers
104 views

Display a Random Number to Display for T Seconds With Millis() for Dice Roller

I'm coding an electronic dice roller for a project. At the press of a push button (A2), the code must display a random number to the two digit seven segment display for 20 seconds, then display blank. ...
1
vote
2answers
374 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 ...
0
votes
1answer
277 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. ...
1
vote
1answer
48 views

My millis() code doesn't work

I am doing a project with bluetooth and an LED. I wrote a code which supposed to turn on an LED after it receives a byte of value 1 after 5 seconds, unless it receive another byte of value 1 (which ...
1
vote
1answer
61 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 ...
0
votes
1answer
40 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
198 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 (...
1
vote
3answers
108 views

Time counting using millis

I am trying to write a code where photoresistors (a or b) sense blinking of the light, and lights LED (k and d) simultaneosly with that blinking. And I want that when both photoresistors sense dark ...
-1
votes
2answers
65 views

buiReliable time in ISR

I'm using a Nano. The code below is a simplified workup of my problem code. The point of it is asynchronous debounced button press detection. The actual code sets a volatile bool to tell the main ...
0
votes
1answer
217 views

Stepper motor based clock movement with DS3231

I am working on a clock movement that is powered using a stepper motor and the GSM2 driver board. The delay between steps needed to achieve 1 rpm on the second hand works out to 25 ms. In my current ...
1
vote
1answer
371 views

Which is better millis() or timer?

I want to create a 30 minutes delay in my program (Arduino). which is better millis() or timer for this purpose? please give me an example to clarify my doubt ... Thanks.
1
vote
1answer
90 views

Arduino Timer0 Piggyback

As described here https://learn.adafruit.com/multi-tasking-the-arduino-part-2/timers I use timer 0 to get my own timer with a milliseconds resolution. It is setup like this: void setup (void) { ...