The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [timers]

Timers are the hardware in the processor used to count and time events. Use this tag for questions about the hardware timers.

Filter by
Sorted by
Tagged with
-1
votes
1answer
28 views

Trying to create a delay function whilst performing other functions, using Timer.h libraries. Arduino uno

I am having a compilation error saying invalid useof template-name 'Timer without an argument list.
1
vote
1answer
23 views

Running loop for a specific time period

I currently have a loop that runs without a time condition: unsigned long previousMillis = 0; // will store last time LED was updated int WET=4;//wet line int DRY=5;//dry line int Inhale=1000;...
0
votes
0answers
24 views

Alternative for Particle Photon's Timer

I am converting a program made for particle photon to a Mega, everything is working except for the interrupt timer. The code that is of concern is (it's a .cpp file being included in the main .ino) ...
0
votes
1answer
45 views

Variable updated in ISR is miscounting

I'm using a timer to fire a interrupt in configurable time periods. In that ISR, a pin is toggled, and a uint32_t variable is incremented. In the main program, a while loop waits until that variable ...
-2
votes
1answer
29 views

Can an arduino Uno control led, sound and smoke?

I'm pretty new to this and I've not seen anyone answer this question yet - so I figured I would ask. I have a vape mod that is set up to expel smoke with a trigger. I want to merge this trigger to ...
0
votes
0answers
36 views

Arduino Every 25k PWM signal

I have written a class for generating a 25khz pwm signal for the Arduino Nano. This works great (pin 9 and 10 only) on the Nano. I want to switch to Arduino Every; this code does no longer work (the ...
-1
votes
1answer
78 views

5 minute timer output time remaining

I am trying to create a timer that outputs the time remaining in minutes. I am using an Adafruit Circuit Playground Express. For example, if the timer is 5 minutes, then every minute it should output ...
0
votes
0answers
49 views

Send ECG data using buffer in real time to the server without using delay

I am trying to make a ECG monitoring system using Arduino, GSM and ECG sensor which data should be sent to the private server in real time. Those data are then collected via Matlab on the remote ...
1
vote
1answer
44 views

Set PWM by period? And have it variable?

In this other stack QA I'm asking about generating a pulse signal with a period ranging from 63 ms to 6.5 ms. There is a popular PWM library however it doesn't compile and also since 63 ...
0
votes
2answers
65 views

control 3 relays with 1 button

Is there a way to control 3 relays with 1 button? My idea is: There are 3 modes; mode 1 for relay 1, mode 2 for relay 2 and mode 3 for relay 3. With a long press you switch between modes (After 3 ...
0
votes
1answer
34 views

Aduino mego TIMER1 one second interval

Can someone tell me is this timer is set correct for arduino mega. It should count exactly one second? And why when i print in serial monitor (seconds_passed++) is incremented by 2 not by 1? Full code ...
1
vote
1answer
27 views

Check if a set of events occur in a limited time period

I am making a project in which I am using 4 Infrared sensors to take an input. The way I want it to work is such that when one of the sensors is triggered, the code listens for input from the other ...
-2
votes
1answer
94 views

how to set buzzer on and off

I have a project that require me to use magnetic contact sensor. I will put the sensor at the door. So the idea is i want every time someone open the door, the buzzer will make a sound, but it will ...
1
vote
0answers
34 views

Turning on controller with button and turning off with a timeout

I am making a device controlled by an ESP 8266 and am wanting to save power by having it power down when not in use. The desired behavior is for a momentary button press or vibration sensor activation ...
1
vote
2answers
44 views

maximum interrupt-based PWM frequency at 500 Hz

I need to control a 24 kHz ultrasonic transducer and decided to use an arduino uno I have lying around. Using tone() or the atmega's hardware pwm is not very suitable because I need two 50/50 square ...
0
votes
1answer
136 views

Timer Countdown to control relay (multiple functions in void loop)

I'm trying to build this project with a simple code. Object is to hit up button to increment minutes or down to decrement minutes then hit start to start countdown, while its counting relay will turn ...
0
votes
1answer
55 views

How to code 4 relays to go off in intervals and not in sequence? [closed]

Code : //FOR AEROPONIC SYSTEM WITH ROOM TEMPERATURE AND HUMIDITY SENSOR //AND 4 GROW CHAMBERS WITH DIFFERENT SPRAYING TIME // RELAY CONTROL #define RELAY1_PIN 2 #define RELAY2_PIN 3 #define ...
0
votes
1answer
28 views

RDTSC alternative for Arduino

To calculate an operation execution time, I was saving the millis() result before and after the operation to calculate the interval time. Is there an alternative on the Arduino Uno like the RDTSC ...
1
vote
1answer
43 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) { ...
2
votes
1answer
61 views

Arduino Timer with increase time button

I have an Arduino project to do, which requires a countdown timer(which I've already done). I connected a push button, and when I press that button I need it to increase my countdown timer by +10 ...
0
votes
0answers
46 views

Why does my TFT keep turning white after moments?

Alright, seems there is something wrong I am doing that I don't understand. Before I start explaining, my question is different than this white screen question. First of all my TFT ST7735 is working ...
1
vote
2answers
51 views

Start / end events using milis

I want to start a relay, have it run for 3 seconds, stop for 10 seconds, repeat. I can't use delay, because I have a motor driver starting / stopping every 100 milis. So I put together this code, ...
0
votes
2answers
102 views

esp8266 deep sleep timer slightly inaccurate?

I'm making a door open timer using a hall sensor and have a wemos d1 mini that uses a deep sleep to sleep for 1 minute after checking the hall sensor state and printing the value on the serial port. I'...
0
votes
2answers
44 views

How to drive Arduino UNO as a counter triggered by 555 timer's output (astable mode)

I have an Arduino Uno and a 555 timer configured to astable mode. What I'm trying to do is to program my Arduino to increase a "counter" variable (counter++) everytime it gets triggered by 555 timer'...
0
votes
0answers
22 views

Moving timer-related code into a separate file causing timing inconsistencies?

I have written the following code, attempting to re-implement the Arduino micros function: main.c #include <avr/interrupt.h> #include <stdbool.h> #define CLOCK_CYCLES_PER_MICROSECOND (...
0
votes
2answers
90 views

How to increase the serial port's data throughput

I have an array of numbers that will be subtracted from the ADC readings of a 50 Hz sine wave. Using Serial.begin(57600);, I can only output 25 samples per sine wave cycle, or about 1,250 samples ...
0
votes
1answer
38 views

Arduino Mega - Enabling CTC mode disables timer

I'm trying to use timer3 on an Arduino Mega 2560 in CTC mode. However, enabling CTC disables the code entirely. Here is the function I call in setup() to setup the times. void SetupInterrerupt() { ...
0
votes
1answer
43 views

How do I start a task and have it run for a set amount of time?

I have a project where I need to turn a 24V solenoid on for a set amount of time, then have it turn off. I am rather new to Arduino and not certain how to do this or really where to start. Ideally the ...
1
vote
1answer
167 views

Measure cycle count and time of Digital Input

I am currently working on a project which is read a digital input signal from a machine. The machine operation is as below: when the mold close, the machine gives the "HIGH" signal, when mold is open ...
0
votes
1answer
350 views

set arduino own timer about 5 minutes

I want to program arduino uno by using it's own timer , which instructions and codes should be used if i want timer to be set for 5 minuets and then warn me about an event , the problem is that , the ...
3
votes
1answer
86 views

Why is no PWM signal generated using Timer 2?

I managed to work with timer 0 and 1 but am unable to generate a PWM with timer 2 in my atmega328p. This is the code: #include <avr/io.h> int main(void) { /* PD6 output */ DDRD |= (1 &...
0
votes
0answers
37 views

PWM C Code some logical error

I don't know what's wrong with the code I have activated all the bits I need. I want the code to slowly increase the brightness of the bulb and then reset and then the same thing goes on. Please help ...
3
votes
1answer
96 views

Code test the duration press of the button

I wrote code that tracks the duration of a button click. It has bounce protection and frequent clicks. (Freeze) My code: bool freeze_time, btn_read, debounce; unsigned int freeze_timer, btn_timer; #...
-1
votes
1answer
191 views

Enable and disable individual interrupts

I am working on timer interrupts and external interrupts. for external interrupts I understood the functions like attachInterrupt. detachinterrupt for individual interrupts ,noInterrupts() and ...
1
vote
1answer
63 views

Force TCNT to stay below OCRxA on ATmega328P

I'm using a timer and the TIMERx_COMPA ISR to generate a signal in "the background". This ISR is triggered when the timer reaches a certain value (OCRxA), which in turn can be changed by the user. ...
2
votes
0answers
71 views

What does “Update of OCR1x at” mean in the WGM table of ATMEGA328?

I just finished a reading a couple of online guides on how to use timer registers with pulse width modulation, so I'm still new to its concept. When I looked in the ATMEGA328 specification sheet, I ...
1
vote
0answers
106 views

Millis() is Not Working

I have a sketch that uses two timers using millis() from a library I created to keep time. The timers seem to be working correctly, but when I print the start time of each timer, it is clearly wrong. ...
0
votes
1answer
152 views

timer library on Arduino DUE

I'm trying to call an interrupt routine (let's call it handler() ) every second on my arduino DUE. I thought the simplest way to do this was to use this library but it seems that i don't know how to ...
-1
votes
1answer
329 views

Handling overflow in micros() [duplicate]

The documentation for micros() says: Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately ...
0
votes
0answers
23 views

TimerOne and Saving Data to SD Card

I'm using TimerOne.h for collecting sensor (two photocells) data with a frequency of 100 ms and saving the data to a SD card. The file only seems to save data when the computer is connected to the ...
0
votes
0answers
432 views

timer interrupts on an esp8266

Folks. I'm working on an ESP8266 and keen to switch to using: an object approach -> sorted; physical interrupts on the hardware pins -> sorted; timer interrupts -> driving me crazy! My problems are ...
-1
votes
2answers
39 views

Can I use a pot to vary duration of timer circuit without writing code for each time interval? [closed]

I would like to be able to use an Arduino as a timer control to switch on/off a 120VAC load. I think I can do that with the Arduino triggering a small relay controlling the 120V contacts. But I need ...
2
votes
2answers
215 views

Button for Delay Select

My target is to make an Arduino system that is able to change modes with different delays by pushing a button. For example, if I pressed the button, it will go into mode 1 with loop 1 that has a 30s ...
0
votes
0answers
182 views

ESP32 changing PWM duty in ISR

I'm implementing code for a multiplexed 7-segment display (4 letters), e.g. it has two common cathodes and each pin corresponds to two segments depending on which cathode is grounded. I have written ...
0
votes
0answers
67 views

How to generate 4 square signals using Arduino Mega 2560 below 30hz using timers

I would like to generate 4 square signals of different frequencies below 30 hz using timers of Arduino Mega. I was able to generate 30.6hz signals but I have no idea how to generate lower frequencies....
1
vote
2answers
54 views

Please Correct my Delay Code without using delay();

This is my loop()function: if(Serial.read() == 't') { tarestate = true; } while(tarestate == true) { timeNowTare = mills(); if(mills() - timeNowTare >= 3000) { Serial.println("Tare"); ...
0
votes
1answer
135 views

Does enabling the Timer1 CompareA interrupt instantly triggers an interrupt?

I am learning Arduino interruptions and I am unable to explain the behavior of a minimalistic interrupt driven project. The project is the following: an Arduino UNO is connected to two LEDs, on ports ...
0
votes
1answer
334 views

How to find the difference between two timestamps

I'm using this time library to access the properties of unix timestamps like hours / minutes / etc. What I want to do is get the current time, and an estimated arrival time, and find the difference ...
2
votes
1answer
225 views

Triggering a soft reset (Arduino Leonardo)

I want to trigger a soft reset on my Arduino Leonardo, and after some searching settled on using the watchdog timer, as it seemed to be the easiest and cleanest way to do it. However, I don't think ...
2
votes
1answer
260 views

Trying to run Timer1 in ATmega2560 with assembly

I have a slight problem with Timer1 in arduino (ATmega2560) while coding it in assembly. I try to run the Timer1 in CTC mode - I configure everything well in my opinion, but the TCNT1 just doesn't ...