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.

62 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3 votes
0 answers
2k 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 ...
walkman118's user avatar
3 votes
0 answers
754 views

tone() and PWM limits

I'm developing an active sonar using Costas arrays and Golomb rulers. I need the Arduino to switch between frequencies very quickly to shorten the length of the ping, both to improve processing and to ...
SimLeek's user avatar
  • 31
2 votes
0 answers
365 views

External Interrupt and Input Capture pin | Arduino MEGA

I have a code for finding the rpm of one system calling here as engine , the engine have a hall sensor output and I have tried the following Code #define SERVO_MIN 2000 #define SERVO_MAX 4000 struct ...
Lawliet's user avatar
  • 183
2 votes
0 answers
96 views

Is a PWM phase duration set with OCR1A a reliable way to communicate values to other Arduinos?

I am working on communicating 4 switch states across multiple Arduinos using only one pin. It must be as fast as conceivably possible. Currently I have a master Arduino reading all 4 switches (...
MeSo2's user avatar
  • 177
2 votes
0 answers
49 views

Generating Externally Triggered Complimentary PWM with Arduino Due

I need a 2KHz complimentary PWM waves with adjustable duty and phase that is triggered by an external 4KHz source. After reading the datasheet I think there might be 2 way to do this: Use a TC unit ...
7E10FC9A's user avatar
  • 209
2 votes
0 answers
1k 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 ...
HixField's user avatar
  • 135
2 votes
0 answers
120 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 ...
Rian Simpson's user avatar
2 votes
0 answers
515 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. ...
Tarlyo's user avatar
  • 21
2 votes
0 answers
1k views

ATtiny85 Comparator C interrupt on timer 1

I have a program that uses Timer1 comparator A in CTC mode. I realize that I need to set OCR1C for the timer to reset at given value. However there is no such thing as an interrupt generated by timer1 ...
Em Ka's user avatar
  • 151
2 votes
0 answers
573 views

Use input capture for multiple sensors simultaneously

I want to accurately time multiple digital input channels (readings from sensors) for the rising and falling edges. I need the precision of the Timer1 Input Capture. As far as I know the input capture ...
Andy Li's user avatar
  • 121
2 votes
0 answers
676 views

FreeRTOS Implementation on Arduino

I am trying to make an RGB LED with Fan Controller for PCs. It is an Open Sourced project. But I want to implement RTOS using this implementation of it as a function in it, namely rollColor(), takes a ...
echo_salik's user avatar
2 votes
0 answers
579 views

Options for turning on/off an output at a specific time?

I am building a night light that will turn on when it detects motion using a Passive Infrared (PIR) sensor. I only want the light to turn on overnight, between specific hours that I specify. Outside ...
MechtEngineer's user avatar
2 votes
0 answers
141 views

Arduino Record pulseIn

I am currently working on a project which requires me to record IR signals. (I realize there is a library available for doing this but I want to learn how to do this myself). I tried using a simple ...
DarkHorse's user avatar
  • 165
2 votes
0 answers
708 views

Using Analog Comparator on Uno to Read Differential Voltage Signaling

I am trying to use the Arduino Uno to read an AVCLan bus on a Toyota vehicle. Logic 0 is when +/- drive are 120mV or more apart, and logic 1 is 20mV or less. See Toyota AVC-Lan description. I ...
Jeff's user avatar
  • 121
2 votes
0 answers
480 views

How to use the timer to generate a pulse wave of the specified frequency and duty cycle

So we have the tone library, which produces a 50% duty cycle square wave of varying frequency, and analogWrite() which produces a fixed frequency wave of varying duty cycle. Is there any way to ...
3871968's user avatar
  • 308
2 votes
0 answers
2k views

Timer CTC Set and Clear modes -- How to un-Clear and un-Set?

Nick Gammon's cheatsheet for the Ardunino UNO's ATmega328P (below) shows some hints on the Clear Timer on Compare (CTC) modes of AVR chips. Most of the examples for CTC mode I find use the COMxxx ...
Dave X's user avatar
  • 2,332
2 votes
0 answers
1k views

Understanding types of timer interrupts

I'm learning this note about timer's api on Arduino Due. Interrupt can be attached with the next function: void tc_enable_interrupt( Tc * p_tc, uint32_t ul_channel, uint32_t ...
kelin's user avatar
  • 145
2 votes
0 answers
68 views

Arduino signed int can't fire timer > 15 seconds

I have tried to use different libraries like TimeAlarms , SimpleTimer, Timer and others. My goal is to call function periodically every minute or so. Each library works fine when repeat time is less ...
dugdthndwytn's user avatar
2 votes
0 answers
898 views

Help reading a 125khz FSK RFID

Reddit doesn't seem to be much help, so I'm posting here as well. I'm try to read (what I think is) an HID Duoprox II 125kHz FSK RFID and am having a bit of trouble. I'm using an Arduino nano and am ...
user1637451's user avatar
2 votes
0 answers
142 views

Rf receiver, change timer

I need some help. I use function rx_setup() оf library VirtualWire.h which is used to transmit information wirelessly. The function use timer аnd there is conflict with any of the other libraries. ...
Supreme's user avatar
  • 73
2 votes
0 answers
2k views

Arduino stops working after some receivings from RF

I made a sketch that receives an rgb code from a remote Arduino using nrf24l01 and while it works for the first receivings then it stops working. I placed a testing Serial.println in the loop to test ...
Christos Mitsis's user avatar
2 votes
0 answers
1k views

Unexpected Timer Conflicts (Uno)

I've been working on a project (Arduino Uno: Atmega328) that implements a gyroscope (which is used with the LSM9DS0 spark-fun library) that is communicated with through I2C and uses a Servo library. ...
Sock314's user avatar
  • 153
2 votes
0 answers
3k views

Which Timer can I use to control a servo with Arduino Uno

I would like to control 2 motors using Timer2 @ 200Hz. The frequency of the timer is printed in the main loop every second. I'm using an Arduino Uno with two interrupt used for the encoders connected ...
UserK's user avatar
  • 559
1 vote
0 answers
132 views

ESP32 trouble with running ledcWrite inside of ISR

ESP32-S2 (Wemos/Lolin S2 mini) Arduino 2.1.1 on Windows 11 Hello, Thank you for taking the time to read this post and for any assistance you can provide. I consider myself a newbie when it comes to ...
Michael.G's user avatar
1 vote
0 answers
185 views

Using library functions in timer ISR ESP32

I'm trying to use a library function in my ISR function that uses the internal timer to trigger every 1 ms. The chip that I'm using is an ESP32-C3-MINI. Here is my current code: main.cpp #include <...
Max's user avatar
  • 111
1 vote
0 answers
729 views

Pulse period capture with SAMD21

I need to count the number of pulses in a moving window (e.g. last 60 seconds) using as less CPU time as possible. The first step is to use TCC to capture pulse period. The pulses arrive randomly at ...
7E10FC9A's user avatar
  • 209
1 vote
0 answers
220 views

Variable frequency PWM, without changing timers

I need variable frequency output - 0-5000Hz with some duty cycle. I do not want to change timers, because I am using delays, serial and CAN, so I do not want them to be affected by changed timers. I ...
Voyze's user avatar
  • 11
1 vote
0 answers
47 views

How do I synch the Arduino PID library with an external timer for turn-rate control?

I have been trying to use the Arduino PID library for controlling the rate of turn (in deg/sec) of a wall-following robot. The robot's operating system uses TIMER5 on an Arduino MEGA2560 to update a ...
starship15's user avatar
1 vote
0 answers
127 views

Arduino mega PinChangeInterrupt with 16 bit timer

With reference to this question ::I have written a program by using 16-bit timer, The program is as follows . volatile uint32_t ovfCount = 0; struct Pulse { uint32_t last_toggle; uint32_t width; ...
Lawliet's user avatar
  • 183
1 vote
0 answers
104 views

How to implementing timer interrupt with a sensor device using A0 and A1 pins

I was wondering if there is a way to program a timer interrupt to collect sensor data at a specific sampling rate? I want to attach two strain gauge sensors to A0 and A1 pins and collect the data at a ...
Dema Govalla's user avatar
1 vote
0 answers
128 views

Consequences of messing with Timer 0

I'm following this tutorial to generate square waves using the timers of the attiny85, but I'm afraid this could mess with something else in the chip. This is the relevant snippet: // Set up Timer/...
IAmJulianAcosta's user avatar
1 vote
0 answers
193 views

Time synchronization of GPS based Wireless Network

I am working on an ARDUINO based wireless network. In this network, each node or device is having its own GPS module. Each GPS module has to get location data and have to send to a single base-station....
Ali Hassan Raza's user avatar
1 vote
0 answers
109 views

Trying to use Timer0 on Arduino Mega

I've recently been looking at Timers and I'm trying to generate a PWM frequency at 250000Hz using Timer0 on PIN 4. When I set OCR0A = 63 I get nothing from the light however when I set OCR0A = 125 it ...
DaveS's user avatar
  • 11
1 vote
0 answers
122 views

How can we get a timer interrupt at a specific time or date?

How can we get a timer interrupt at a specific time or date? For example: I want to make a project with an Uno and I'm using sleep mode and the wake-up source is timer2, as per the ATMega328p ...
sepehr's user avatar
  • 63
1 vote
0 answers
60 views

arduino cont down timer in minutes with out using delay

i have one code with delay pleas help me remove the delay i will using this code in air cooler with some sensors delay stop working sensors void startCycle(int cycleTimeInMinutes, const char *type) { ...
Hemanth Kumar's user avatar
1 vote
0 answers
74 views

Using interrupts to facilitate time-keeping

I am making a clock on an Arduino Mega using interrupts to facilitate time-keeping. The following is my timer breakdown: Timer0: Used for my calls to millis() which allows me to determine when a ...
peachykeen's user avatar
1 vote
0 answers
237 views

Arduino Due: Measuring the time between pulses

I have a 'pulse train' generated from a photo interrupter and slotted disc mounted on a rotating shaft. My goal is to measure the time between each rising edge. I have looked at the data sheet for ...
Andrew McBurney's user avatar
1 vote
0 answers
93 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) ...
Will Buxton's user avatar
1 vote
0 answers
219 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 ...
Miloš Mladenović's user avatar
1 vote
0 answers
520 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 ...
Noajm IsMy Name's user avatar
1 vote
0 answers
1k 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 ...
DavidA's user avatar
  • 11
1 vote
0 answers
245 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....
AVVARU CHANDRIKA's user avatar
1 vote
0 answers
265 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, ...
Erik's user avatar
  • 261
1 vote
0 answers
477 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 ...
idalurf's user avatar
  • 11
1 vote
0 answers
40 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 ...
Dominic Teo's user avatar
1 vote
0 answers
115 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 ...
mahdiou's user avatar
  • 11
1 vote
0 answers
174 views

How to drive RGB LED fading alongside MAX7219s

Merry XMAS I have a pro mini which drives 2 RGB LED strips on its 6 PWM pins, via 6 2N7000 N-channel MOSFETs. Alongside these, I have 4 x MAX7219 modules in series controlled via SPI. Both work ...
user400344's user avatar
1 vote
1 answer
1k views

Reduce PWM Frequency Arduino DUE

I'm newbie in arduino due. I need to reduce the default PWM frequency of arduino Due. Anyone have any tutorial to do this? (Frequencys like 25hz, 50Hz for example) I read in some posts, if i change ...
FelipeFonsecabh's user avatar
0 votes
0 answers
147 views

SDI-12 protocol, working with SoftwareSerial

I have a Teros 11 moisture sensor that I have managed to make it work with the SDI-12 arduino library. However, this library does not work with SoftwareSerial and this is critical for me. There is a ...
user1584421's user avatar
  • 1,395
0 votes
0 answers
37 views

Not getting input from sensor using timer

I wrote a code to move linear actuator and lights up and down using timer. But its not getting Sensor input please help me in this. #include <avr/sleep.h>//this AVR library contains the methods ...
Noman Gulzar's user avatar