Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
608 views

Arduino Zero - Stepper control (interrupt)?

I have a stepper controller board that I need to pulse every 40 uS or so. I also have I2C sensors and Serial writes to preform. Currently I run an update call in a tight loop, but the I2C sensors ...
1
vote
1answer
538 views

Timer0 overflow interrupt not working

I try to use the Timer0 of an Arduino Leonardo (ATmega32u) to trigger an interrupt at regular intervals, using plain avr-gcc (not the arduino library). I try to blink the built-in LED as test, but it ...
2
votes
3answers
371 views

Moving wiring.c functions from timer0 to timer1

I am using an Arduino Leonardo (ATmega32U4) and need to use timer0 for PWM. Since by default in the wiring.c file the functions micros() and millis() use timer0, I decided that, since timer1 isn't ...
1
vote
1answer
40 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
57 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
67 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
34 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 ...
2
votes
1answer
75 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
33 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
40 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
32 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
48 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
41 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
vote
2answers
206 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 ...
-1
votes
1answer
94 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
21 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
90 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 ...
0
votes
0answers
70 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
36 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
51 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"); ...
1
vote
4answers
2k views

Generating a 38 KHz signal without timers

I am currently trying to generate a 38 KHz signal for my TSOP4838 (http://www.vishay.com/docs/82459/tsop48.pdf) with an ATtiny84A. I know the real thing would be to utilize a timer but the ATtiny ...
1
vote
1answer
686 views

ATSAMD21 sleep + watchdog?

Has anyone got sleep/standby + watchdog to work together on their Arduino Zero or Sparkfun SAMD mini? I am able to get the WDT to reset the device, and am able to put it to sleep - but can't get the ...
1
vote
2answers
272 views

Attiny85 Timer 1 comparator B doesn't work properly (while A does)

I'm writing a simple program that is using Timer 1 comparator B to generate a square wave on DEBUG_PIN. So my code at first turns on timer 1 with prescaler 8192 so that one tick is approximately 1ms....
0
votes
1answer
75 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
203 views

generate two phase-shifted PWM pulses triggered by frequency-divided external signal with Arduino uno?

I have a 4kHz pulse as trigger and I need two phase-shifted PWM output with divided frequency from arduino uno. Now I've managed one PWM output using the following code: int cnt = 0; void setup() { ...
0
votes
1answer
101 views

How to force exit from a interupt?

I have problem with Interupt, i don't know when it happen problems, when it have error, it do not run Reti. How can i force exit it in watchdog interupt ? ISR(timer5Event){ digitalWrite(...
0
votes
1answer
79 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 ...
0
votes
2answers
222 views

Inaccurate PWM Signal Frequency and Timing

I have a Teensy 3.2 and I am using the Arduino IDE to program it. I am trying to generate 8 pulses with the frequency of 40 kHz and this needs to be repeated every second. I have written 3 different ...
2
votes
1answer
103 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
134 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 ...
2
votes
2answers
323 views

How to read a timer's value once stopped?

I've downloaded the Timer1 library but unfortunately it seems that the read() method has been removed from it. I tried also SimpleTimer library from the arduino website but the program didn't compile ...
2
votes
1answer
5k views

Arduino continuously reading ADC value using interrupt

I have a mono jack audio act as analog input for arduino UNO. The microphone outputs voltage that varies in terms of amplitude (volume) and frequency. In order to get the high sampling rate, I use ...
0
votes
1answer
41 views

How to set time for 15 seconds

When user used one password after close the servo the password will valid for 15 seconds then it will not work. Other 9 will be same process Here is code I need just this to set int locker = 13; ...
0
votes
1answer
66 views

Can I use arduino to generate 8mhz frequency ultrasonic pulses in piezo discs?

void setup() { pinMode(freqOutputPin, OUTPUT); Serial.begin(9600); // Set Timer 2 CTC mode with no prescaling. OC2A toggles on compare match // // WGM22:0 = 010: CTC Mode, toggle ...
0
votes
1answer
50 views

Using timer classes within classes

I am trying to develop a class for a pump that works on a stepper motor, it should be simple but its not working the way I thought it would. Once I move the timer object into the class the code wont ...
8
votes
4answers
1k views

Turn Arduino on with timer every 24h

I'm currently working on an Arduino project that sends the charge of my car battery once a day via an ESP8266 to me. During the winter I don't drive my car, and I would like to get informed when the ...
0
votes
1answer
58 views

What is the smallest duration that can be measured using micros()? [closed]

What is the least value of time that I could measure(count) using micros()?
0
votes
1answer
202 views

how to increase the delay factor of DHT11?

There is no compiler error but output is showing timeout error. as per as the instruction given in https://github.com/RobTillaart/Arduino/issues/61 it says to increase the timeout factor but i did ...
0
votes
1answer
2k views

ATtiny85 AC Phase Control for dimming a light bulb

I'm trying to dim a light bulb via an ATtiny85, which accepts commands sent over I2C. My problem is that the bulb is barely dimming and is flickering quite a bit. My circuit can be seen here: The ...
0
votes
2answers
34 views

Timer with ajustable time delay

I have a led strip, and each led should be turned on sequentially, such as this one: [http://1.bp.blogspot.com/-CTT6yvYtdos/VihhhBItwjI/AAAAAAAAAvM/q1jbUylMMdM/s400/ezgif.com-video-to-gif.gif][1] The ...
1
vote
2answers
111 views

Elegoo Nano timer prescaler problem

I am trying to use Timer2 on an Elegoo Nano to produce a "tick" interrupt every 10uS. My plan was to set Timer2 to CTC mode with a /8 prescaler (to get a timer clock of 2MHz from the 16MHz chip clock) ...
0
votes
2answers
38 views

Read sensor data repeatedly after specified time?

I want to read sensor data using analogRead() after every 5ms. I have read other answers to similar questions but what I'm confused about is: let's say, I made a loop to read sensor data using ...
0
votes
1answer
191 views

LiquidCrystal library and timers don't seem to be compatible

If I set timer2 to Compare Match mode, my LCD display stops working. If I use Overflow Interrupt it works fine. Here's my test code. I have a loop() function which does its thing, and a timer ...
1
vote
1answer
302 views

Arduino timer ctc mode 4 vs 14

I'm trying to gain an understanding of the Arduino timer and interrupts, particularly the CTC-modes 4 and 12. I wrote a small example in which I generate interrupts while the mainloop sleeps for 1 ...
0
votes
2answers
395 views

Getting FFT arduino code to run over 9+ hours, utilizing micros()

I am a beginner in Arduino, coding, and electrical engineering (learning on my own time) and am working on creating an EEG. I've got the hardware down and have managed to get numerical data output ...
3
votes
1answer
3k views

TCCR1A and TCCR2A on Leonardo

I'm trying to use the TTS library for Arduino on an Arduino Micro board, which is based on the Leonardo. When I try to compile my sketch I get some errors; /libraries/TTS/TTS.cpp: In function 'void ...
0
votes
1answer
94 views

Watchdog Timer for atmega 128

I am using atmega 128 for a smart vehicle tracker. I am trying to use watchdog timer for this controller.But problem is that I have found the maximum watchdog reset time is 2 seconds. I need watchdog ...
1
vote
2answers
173 views

Input Capture Pin Atmel ATmega328P

I have some code that relies on the input capture timer value. I assume the timer value (as defined by the pre-scaler etc) is not affected by other code running i.e. it is updated every nth clock ...
2
votes
4answers
11k views

Creating a timer using a Real Time Clock with start and stop times

I have an Arduino Uno with a motor shield, as well as a DS1307 RTC that I am using to control 2 pumps. Ideally I would like to set a start time (startHour + startMinute) and end time (endHour + ...