Stack Exchange Network

Stack Exchange network consists of 174 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.

1
vote
2answers
47 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
28 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
36 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
41 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
61 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 ...
0
votes
1answer
37 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
50 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
36 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 ...
0
votes
1answer
47 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
94 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
2answers
31 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
86 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
34 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
2answers
206 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 ...
0
votes
1answer
67 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 ...
4
votes
1answer
378 views

Why are Arduino timer registers not 0?

I'm trying to use the timer registers to do some timing on my Arduino Mega 2560. The output of the following code confuses me: void setup () { // Set up serial connection Serial.begin(9600); ...
3
votes
1answer
50 views

Timer interrupt triggers too often

The following question is based on the Arduino Pro Mini (8MHz, 3.3V) I'm in process of developing (yet another) LED strip driver shield. For that I wrote a simple control loop, that adjusts the ...
0
votes
0answers
50 views

How to enable TIMER/COUNTERS of arduino uno with a push button?

This is my code for stopwatch. I want the timer to start when a push button is pressed. #include <LiquidCrystal.h> #define PIN 2 const uint16_t load = 0; volatile int sec=0; unsigned int ...
3
votes
4answers
359 views

How to make 1 second delay more accurate?

I have written two (1 second) delay programs. The first program as follows: void setup() { Serial.begin(9600); TCCR1A = 0; TCCR1B |= (1<<CS12); TCCR1B &= ~(1<<CS11); TCCR1B &=...
0
votes
1answer
114 views

Generate single pulse from timer 1 in arduino nano

i have a code that shot a single pulse from pin D5 timer 0 (based on josh levine code), it works fine. the code is below #define OSP_SET_WIDTH(cycles) (OCR0B = 0xff-(cycles-1)) void osp_setup(uint8_t ...
-1
votes
1answer
53 views

Arduino code to run 2 thing simultaneously [closed]

I am making a project for my college in which I need to measure the rpm of the motor and show the real-time clock on the 128x64 GLCD simultaneously but when I run the project it only shows one thing ...
2
votes
1answer
212 views

Generating 200 kHz pulse on Arduino Uno in normal mode

I need to obtain 200 kHz from Arduino Uno. I am using Timer0. I have configured it to run in normal mode and the Prescaler is set to clk/8 (the clock frequency of Arduino is 16 MHz). TCNT0 ...
0
votes
2answers
133 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 ...
0
votes
0answers
139 views

50% duty cycle on phase-correct PWM on Timer 2

According to Ken Shirrif's article, Ken Shirriff's blog - Secrets of Arduino PWM (and the same article on the Arduino pages - Secrets of Arduino PWM), under the section Varying the timer top limit: ...
0
votes
2answers
88 views

Unable to obtain pulse train at 32Hz with 20us pulse width with Uno

I tried to obtain 32Hz pulse train(between 30Hz and 35Hz is also fine) with around 20us pulse width with Arduino Uno but couldn't succeed. The problem is: If I do the following: void setup() { ...
0
votes
1answer
265 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 ...
1
vote
1answer
118 views

Timer frequency calculation for UNO/Atmega328

I must be overwrought or something... I just can't get the calculation of the timer frequency right. I have a 16 MHz crystal on the Atmega328. I want 1 kHz timer interrupt rate. So I chose prescaler = ...
1
vote
1answer
111 views

How to add additional millisecond delay to microsecond delay generator

I am trying to make a delay generator. I already found an excellent example in Generating a short pulse after a delay that works in the range from ~5-32767 microseconds (it is limited by a 16 bit ...
1
vote
1answer
223 views

Timer2 Compare Interrupt not working as expected

To get this out of the way first: I have already looked at "Timer2 does not work as it should" and "Timer2 “Clear OC2B on Compare Match” not working as expected in CTC mode" but have not found the ...
1
vote
1answer
145 views

TimerOne Library - Response time

I'm trying to write a library for (rather slow) communication with visible light and have recently tried to include the TimerOne library as a timer. I want to send bits at 2kHz, so with a period of ...
0
votes
1answer
79 views

How to create “Auto switch case”

I am new to programming. I want to modify this sketch and I really need help. I have a switch case in this sketch, and what I want is an auto change effect. In this sketch 18 color effects for ...
0
votes
1answer
99 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 ...
0
votes
1answer
64 views

atmega88 timer2 32.768KHz and Serial problem

I am trying to use atmega88 timer2 with a 32.768KHz crystal. I'm using a slightly modified version of Nick Gammon's code. I am using Minicore. No bootloader, 1MHz clock from internal oscillator, BOD ...
0
votes
1answer
144 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
0answers
34 views

StepperLab3 library and Liquidcrystal

I want to control a stepper while displaying user menus on a freetronics style 16x2 LCD. I'm using liquidcrystal for my menus and in order to get non-blocking control of the stepper I've imported the ...
1
vote
2answers
518 views

Issue in long ON OFF timer using millis()

I have 3 components: a relay and two LEDs...I want two timers using Arduino... In timer one, relay should be off on; one LED is off; and other is on...In second timer, relay is off; one led is on; ...
0
votes
0answers
225 views

Counting pulses of a signal between 2 pulses of another signal

I set an Arduino Nano to read the time between 2 pulses of a signal (kind of rotary encoder) to get and display an rpm value. I've done this using interrupts. Now I'd like to add a second (kind of) ...
0
votes
1answer
271 views

Clock generator up to 8 MHz using pin 3 arduino nano

I would like to generate square signal up to 8 MHz using internal timer of arduino, I have done successfully in pin 11, but i want to change it in pin 3, but still stuck. Here is the code pinMode(11,...
0
votes
0answers
55 views

Due timer update

I want to test a BPM counter as a part of larger project rewriting code for a groovesizer synth. In essence i want to read a pot for updating BPM tempo, and then have a LED blink that tempo, ...
0
votes
0answers
88 views

PCM library - Timer0

I would need a quick help if possible because I have a project with the deadline tomorrow night. On my Uno (atmega328p in fact), I need to communicate with a SPI flash to transfer music and then, take ...
0
votes
2answers
296 views

Can I simulate a clock without an RTC connected? [closed]

I want to program for a timer that works as set timer such as in an oven where user can set their own time. One of the way I know is using an IC(RTC) for the timer. However, I don't have the IC yet ...
1
vote
1answer
354 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 ...
0
votes
0answers
59 views

How to change the timer associated with Arduino Micro's pin #5

From the datasheet and Arduino code, what i understood is that pin PC6 supports PWM and has two timers are associated with this pin. //from pins_arduino.h D5# PC6 ??? OC3A/#...
0
votes
0answers
28 views

Having a timer run parallel to while listening for button presses on a TFT

I'm currently working on a project that uses an Arduino Mega 2560, a Vibration sensor and a TFT LCD (Kuman Uno R3). I created a GUI that basically permits me to enter a passcode into a textfield and ...
0
votes
0answers
29 views

Timer Interrupt Default Settings

so I am testing out the PulseSensor code from here: https://github.com/WorldFamousElectronics/PulseSensorAmped_2_Sensors/tree/master/PulseSensorAmped_2_Sensors_1.5.0 In the interrupt.ino file, there ...
0
votes
0answers
45 views

Cons of using timer0 with external input?

I'm working on a project of differential drive control in which I use speed encoders for the odometry. I count the number of rising edges using counter0 and counter5 (on Arduino Mega 2560), which ...
0
votes
0answers
64 views

Arduino multitasking with timing

I have small problem, i need to time 2 tasks so that they will work independent. I have code for 1 axis and code for 2nd axis, while the code works good on one axis it completely freezes when trying ...
0
votes
0answers
266 views

Using the TimedAction library

I need to make use of the TimedAction library for a project. The Arduino website gave an example of how to use this library which you can see here: #include <TimedAction.h> //this initializes ...
0
votes
1answer
114 views

What is better approach for non blocking pid algorithm?

I'm developing software side for 3 axes robot where are 360° continuous rotating servos used Documentation here these servos have its own feedback system so it's possible to control it's position ...
0
votes
0answers
20 views

Slot time measurement curves digitalize for an old Tektronix

I'm using a Tek576, curve tracer for semiconductors or other devices. Unfortunatly it's not possible to store the curves on this old devices. The idea was to digitalize X,Y signals directly taken (...