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
0
votes
2answers
408 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
39 views

Problem with programming digispark ATtiny85 board with Arduino IDE

I have bought a Digispark ATtiny85 board to learn about that microcontroller. So I tried using internal register names in the code rather than using Arduino in built functions. I can get the board to ...
-1
votes
2answers
79 views

Is there a way to get about a 10ns Timer resolution from an AVR CPU?

I have an 8Mhz ATM32u4 that is able to read external pulse inputs at 125ns ticks using InputCapture3 (PC7) on its 16-bit timer. Is there a magical way (bitbanging?) to get around 10ns tick resolution ...
1
vote
0answers
30 views

Equipment wireless stopwatch

I am working in a project in order to measure spend time. My sitution is: There is a competitor that will start the game after he (or she) heard a sound (could be a sound like buzz or whistle). This ...
1
vote
1answer
25 views

Timers, PWM pins and digital outputs on Arduino Mega

I'm using an Arduino Mega to control motors via PWM and Adafruit DRV8871 motor drivers. I also use TIMER1 for a timed interrupt. After adding the TIMER1 interrupt I discovered I had problems with ...
0
votes
1answer
26 views

Input Capture with Sleep Enabled on ATM32u4 board only works every second reading in SLEEP mode

In short: I have an Input Capture code and a Power-Saving code combined into one program. Both are adapted from Nick Gammon's examples that work fine independently. When I combined them into one ...
1
vote
3answers
165 views

How to save data in arduino when it's power goes off

I am doing a project 'arduino based switch operation'. Here the user needs to set a time to turn on relay and set time to turn it off. The problem is that I want to supply power to arduino using ...
0
votes
1answer
72 views

Arduino Asynchronous Function Crash

I'm trying to make two functions one will be running in a loop the second one will be running with a time interval of 1 seconde I made a piece of code to do so it runs fine in the beginning but after ...
2
votes
2answers
281 views

How do I make LEDs lights up one by one according to how long the button was pressed and hold

In my project, I am trying to create a timer display with LEDs base on how long a button was pressed and hold. There are 8 LED lights in total, when the toggle button was pressed, 1st LED lights up; ...
3
votes
3answers
142 views

Programming Arduino Uno R3 to trigger a relay once every 24 hours

I programmed Arduino UNO R3 to trigger a relay once every 24 hours from the moment it is powered on I calculated milliseconds and used the function delay() 24 hours * 60 minutes each hour * 60 second ...
0
votes
1answer
855 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
44 views

help explain pulseIn function with arduino and Ultrasonic sensor

dears Engineers.. i got stuck with this issue couldn't understand.. please help with explanations. first i was upset of my ultrasonic sensor reading deviations, that is i examine my sensor indoor and ...
1
vote
1answer
30 views

Is it possible to detach an interrupt for a certain ammount of time

Hardware: Arduino Uno Software Version: 1.8.13 My sketch has an interrupt service routine that triggers with the rising edge of digital pin 2. What I want to do now is detaching the interrupt as soon ...
1
vote
1answer
36 views

Can it time between blips, store the time between blips, subtract one time from the other and divide one time by another and display it?

I am counting rotations of a shaft and timing events that occur during that rotation. I wish to display the event timing as a percentage of ~1/4 of the rotation timing. This would involve recording ...
0
votes
1answer
1k 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
2answers
114 views

Detecting an incoming 7.875 kHz pulse to use as trigger

I have written a code that detects an incoming pulse (square) of 7.875 kHz to trigger the output High for the entire duration of pulse, and trigger the output low if the pulse is off or not detected. ...
0
votes
1answer
138 views

DS3231 + button to trigger light

please can someone help me with code, i want to have automatic trigger on specific hour, also i want to have button switch if needed, in my code i can press the button to trigger light relay, but my ...
0
votes
3answers
237 views

How can I set a timer?

I would like to set a stopwatch timer that will determine how long an input is in a certain state before changing. I want to set it so that, depending on the output my code executes one of 2 switch ...
3
votes
1answer
157 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
1answer
37 views

Timer question: Phase Correct PWM at specific frequency

I am trying to create a sinusoidal wave segmented in 64 Frame, each holding a Duty cycle precisely varying from 0x00 to 0xff. This is for an Arduino Nano. I have trouble understanding the following: ...
0
votes
0answers
27 views

I am making my blinds automatic, but I don't want to use a delay

I am trying to make it so I can pull the time so that they open at 8 am and close at 10 pm. The loop is already set up to open and close the blinds completely. #include <CheapStepper.h> ...
0
votes
2answers
85 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
30 views

esp32 pico kit - actual clock speed vs crystal vs max_speed etc

I am trying to understand how the clock speed in the esp32 works. I am running arduino ide 1.8.12 with 1.04 board definition - on a pico kit 4 module . The device datasheet says it has a 40mhz crystal....
0
votes
0answers
24 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/...
0
votes
2answers
32 views

How to specify a timer's name depending on the chip it will be compiled to?

I need to enable a timer interrupt for a chip, and in the mean time, I am testing the code on Arduino Nano rather than (feed the chip, test the chip)++. So as part of the code I have to TIMSK0 |= (1 &...
-1
votes
4answers
3k views

Strange problem. Arduino stops working after few hours. Opinions please

I am trying to setup an automated relay for my aquarium. The Arduino should switch off the pump every 3 hours for 20 minutes, and feed at particular times during the day. The code works fine for the ...
0
votes
1answer
26 views

Wire Library Timer Usage

I would like to know if the Wire Library is using a Hardware Timer from the Arduino Mega 2560. And If so which Timer it is. As I am using the Timer 1. After implementing the Wire Library I have some ...
2
votes
1answer
60 views

Mega: attachInterrupt on pin 18/19/20/21 not working

Task: I'm trying to create a fan-control with the arduino mega. I'm generating a PWM signal on pin 6 and 7 and want to use interrups to measure the rpm of the fans. Problem: On pin 2 and 3 everything ...
0
votes
2answers
86 views

How to keep track of millis during sleep mode

In my application, I need to keep track of the time the application has been running as well as use sleep modes. However, when using the sleep modes, Timer0 is disabled, and therefore millis stop ...
0
votes
2answers
43 views

Send data before raising edge of a Clock

I'm trying to control a LED strip that has a custom protocol (developed above of I2C). But in my tests i was successful figuring out how it works : You set Clk to zero , you send a bit in the data ...
0
votes
1answer
78 views

Arduino Mega TIMER1 one second interval

Is this timer set correctly for Arduino Mega? It should count exactly one second. And why when I print in serial monitor (seconds_passed++) is it incremented by 2 not by 1? Full code on Pastebin: ...
-1
votes
2answers
78 views

Running a motor for a 3 seconds continuously with and without interrupt

I have interfaced a dc motor and IR sensor to my nano. The DC motor is supposed to run only if the IR sensor detects an obstacle. Now, I'm trying to get the motor to turn off if continuously ...
0
votes
0answers
17 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....
0
votes
1answer
186 views

Faster TimerOne with Teensy 4.0 (600MHz)

I have a teensy 4.0 which runs at 600MHz, and is double superscaler (i.e. can execute two instructions per clock cycle, sometimes). I need an interrupt to happen faster than every microsecond. I've ...
1
vote
1answer
111 views

Arduino Timer Precision

I am using the ATMega32u4 to generate multiple pulses at 2.5 kHz. I am using Timer 3, which is a 16-bit timer and using a prescaler of 1, so I have a 0.0625uS resolution. I want to generate pulses ...
3
votes
1answer
71 views

Timer Accuracy Always off by 1uS

I am using the ATMega32u4 to generate a pulse at 1 kHz. I am using Timer 3, which is a 16-bit timer and using a prescaler of 1, so I have a 0.0625uS resolution. The good news is that this is working, ...
0
votes
1answer
38 views

very small PWM when timer says zero

I'am getting a little PWM signal when my potentiometer is at zero and OCR2B always reads zero on the serial monitor. My LED has low forward voltage but I still get a little PWM on the pin when I prob ...
1
vote
1answer
81 views

Interrupt every second on ATTiny84 (and sleep the rest)

I'm building a digital watch just like in this post, except I'm using an ATTiny84. However, the ATTiny84 doesn't have an asynchronous Timer2 like the ATMega328 and does not have a power save mode, so ...
-1
votes
1answer
51 views

Why doesn't this timer code work?

Why doesn't the code below work? Timer will count 370ms then function called to ON LED. Again 370ms then function called to OFF LED. Basically a toggle function. int IN0 = 12; int IN1 = 11; int OUT1 =...
0
votes
1answer
54 views

can we use Software serial and timer one at the same time or this software use also timer one? [duplicate]

i am using timer1 and software serial for gps data i need to see if we have a problem with connection . So i made a timer1 that's start before the loop that will wait the gps sending and after 3s if ...
0
votes
1answer
71 views

ADC value changing after changing Timer1 value in program

I'm writing a code where analogRead() reads ADC value from load. After reading ADC value, if it is not in range, I need to manipulate Timer1 value. Which is also getting changed. But, after changing ...
-1
votes
1answer
85 views

Data in two 8 bit shift registers won't change

I'm trying to output 16 bits of data to two 8 bit shift registers (74HC595), which drive a 8x8 led matrix. There is a problem with the way the code outputs data to the registers, its like no data is ...
1
vote
2answers
116 views

Arduino Timer 1 Library manipulate Timer value

I'm using Timer1 library for generation of pulse. But in my code, at some places i need to change the timer values. Can anyone suggest the ways to do it. In below code in place of 370000, I need to ...
0
votes
0answers
46 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 ...
0
votes
0answers
52 views

Controlling a Ultrasonic driver board with Arduino

I Have a Ultrasonic driver board that is activated with a momentary switch acting as a toggle (click turns it on - click again turns it off). As the main chip has no writing on it, how would I probe ...
4
votes
1answer
9k views

How to fix compilation error for tone() using same timer as other function

I am trying to integrate tone() with the open source program for the Amped heart rate monitor. The error: Tone.cpp.o (symbol from plugin): In function `timer0_pin_port': (.text+0x0): multiple ...
-1
votes
2answers
86 views

Serial.println() not working in ISR

Please refer my below code, const int led_pin = PB5; const uint16_t t1_load = 0; const uint16_t t1_comp = 43750; int blinkcount; void setup() { // put your setup code here, to run once: DDRB |= (...
0
votes
0answers
36 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) { ...
2
votes
1answer
124 views

Can't use millis() instead of delay

I am making a home coming/leaving light for car. First I want that whenever I press the car key lock, a timer will start for 10 seconds. And if I press a button twice within 10 seconds, pin 13 will ...
0
votes
2answers
771 views

How to measure ultrasonic sensor without pulsein method?

I am a front-end developer so I don't really know Arduino. Anyway, my teacher gave me a project. In short, I have to measure distance with HC-SR04. But the problem is that the teacher wants me to ...

1
2 3 4 5
8