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.

50 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
0answers
54 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 ...
2
votes
0answers
437 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 ...
2
votes
0answers
873 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 ...
1
vote
0answers
76 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. ...
1
vote
1answer
652 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 ...
1
vote
0answers
638 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 ...
1
vote
0answers
326 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 ...
1
vote
0answers
495 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 ...
1
vote
0answers
118 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 ...
1
vote
0answers
450 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 ...
1
vote
1answer
719 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
0answers
836 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 ...
1
vote
0answers
54 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 ...
1
vote
0answers
644 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 ...
1
vote
0answers
122 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. ...
1
vote
0answers
940 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. ...
1
vote
0answers
2k 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 ...
1
vote
0answers
152 views

Sketch not giving feedback as predicted switching from Arduino Uno to Nano

I have a sketch that works just fine on my Arduino Uno board, but somehow mess up, when I try to retrieve data from a Nano Board. I have wired a TCS230 color sensor, to get data about some colours. I ...
1
vote
0answers
638 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 ...
1
vote
2answers
292 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
0answers
36 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 ...
0
votes
0answers
16 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
1answer
150 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 ...
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 ...
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
263 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 ...
0
votes
0answers
134 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
51 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....
0
votes
0answers
92 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 ...
0
votes
1answer
249 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
41 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 ...
0
votes
0answers
103 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
152 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
0answers
32 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
70 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
532 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
0answers
1k views

Measuring Time while using interrupt pin

I have a very fast signal connected to pin2 of an Arduino Mega 2560. The signal is a square wave of approximately 500 000 Hz. I would like to measure the frequency of this signal. First approach ...
0
votes
0answers
105 views

R24 Incompatibility with TimerOne on Nano

I am attempting to build a sketch on a Nano which receives a regular pulsed signal from an NRF24L01+ board and uses the time-interval between pulses to generate a regular pulsed output generated by an ...
0
votes
0answers
210 views

Stuck at initializing input capture

I am using MEGA 2560 with 1.8inch TFT screen. I am trying to use input capture (shown in the code below) feature along with TFT display (1.8inch TFT display). Now when I individually test the input ...
0
votes
1answer
642 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 ...
0
votes
0answers
397 views

How do you program to make a random timer to start and stop to music?

I need to program a timer that will work randomly to any music playing in the background. The timer starts when the music starts and timer stops when the music is stopped. How do I do this?
0
votes
0answers
116 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 ...
0
votes
0answers
427 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 ...
0
votes
1answer
914 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 ...
-1
votes
0answers
24 views

How to create a phase delay of 30 degrees in PWM using timer registers

I am trying to generate the PWM pulse of 157khz with zero degree and 30 degree phase delay. I obtain the zero degree delay. How can I phase shift 30 degrees?
-1
votes
1answer
463 views

Countdown sometime stop

I've made a game with 3 countdowns and 1 global countdown. When we start, the global one, go from 45:00 to 00:00. The 1 go from 15:00 to 00:00 and if it reach 00:00: The 2 start and go from 15:00 to ...
-1
votes
1answer
275 views

Picking the time a led on an arduino should turn on, via android

I have created an app which is connencted to my arduino via bluetoth. The user of the app can turn on and off a led which is connented to the arduino. But I want to take it a step further... I want ...
-1
votes
1answer
82 views

Separate Timer Instance

I'm trying my best attempt here after failing in Googling the answer, but here goes: I'm trying to get a separate instance to start running in the background when a pin goes HIGH. How should I ...
-1
votes
1answer
112 views

How to use TimerOne while calculating time?

I'm trying to get warning with buzzer while I get same values on 3 seconds. But first warning doesn't wait 3 seconds. Second warning is correct. Code is attached. BlinkLED1() method is same BlinkLED2. ...
-1
votes
1answer
563 views

Password code using interrupts and timers on Arduino Uno

I have a group project where we are trying to make a user enter a password that we have pre-selected for them. They enter the password using tactile buttons, and they have 5 tries to enter the ...