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

I have 2 Arduino programs that work separately. How can I merge them? [duplicate]

IMPORTANT* I am new to this. A virgin to code I dont understand the millis function I have two solutions in mind but uncertain of how to format Solution 1) use scheduler / or millis to ledR high for ...
0
votes
1answer
28 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
25 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
1answer
30 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
0answers
28 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
22 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
29 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 &...
0
votes
1answer
21 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
50 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
54 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
41 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
0answers
16 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....
-1
votes
2answers
73 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 ...
1
vote
1answer
94 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
66 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
31 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
72 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 ...
0
votes
1answer
70 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
83 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
97 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
1answer
47 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
0answers
43 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
50 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 ...
0
votes
1answer
57 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 ...
-1
votes
1answer
50 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 =...
-1
votes
2answers
80 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
33 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
115 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
0answers
93 views

Detecting the stop of execution of a timer interrupt

This is my timer interrupt: void setup() { attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), count_time_of_k_pulses, RISING); pinMode(OE_BAR_PIN, OUTPUT); pinMode(S0_PIN, OUTPUT); ...
-4
votes
1answer
49 views

Plotting analogRead on OLED (128*64) - EspWemos D1 mini (Problem to upload this Sketch) [closed]

i want plot real time analog input on OLED . This code for arduino Uno .. i tested on arduino uno and take perfect answer. but i using OLED-Wemos D1 mini Shield board. and i want upload this code on ...
0
votes
3answers
125 views

Getting wdt reset + reboots every 5 seconds on simple button/relay code that has worked previously, now it does not and I changed nothing

I have some arduino code I adapted from a simple 2 button 2 relay code I found online. I just multiplied everything so I could have 5 buttons/5relays. I am using a NodeMCU (ESP-12E) for this. I have ...
0
votes
0answers
32 views

Why does this scope-based timer not work as intended?

I wrote the following scope-based timer to help me profile my code and improve its efficency, but in testing I found that it reports durations far shorter than it should: class CodeTimer { public: ...
1
vote
2answers
123 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
117 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 ...
0
votes
1answer
395 views

Unable to compile SimpleTimer code - Exit status 1

I downloaded the SimpleTimer library from the Arduino's library manager and navigated to Arduino Playground website for some sample code for testing - SimpleTimer - Arduino Playground. After copying ...
0
votes
3answers
222 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 ...
0
votes
0answers
34 views

FlexiTimer giving errors in servo motion

I am working on a quadruped bot, spiderbot and I am trying to make a creep gait using Forward kinematics however, for some reason my code stops working after the execution of the line - [pwm.setPWM(...
-1
votes
2answers
143 views

Detecting when a timer interrupt does not run

I am dealing with code thatt i received that relies heavily on timer interrupts. i am using arduino Mega (Funduino) More specifically, when a signal arrives in a pin, an interrupt is run that starts ...
0
votes
1answer
33 views

Missing time when using timer

I have set up Timer2 to count every tick at 16MHz, or 62.5ns per tick. Then I run the following code: int t = 0; for (int i=0;i<64;i++){ data[4*i] = TCNT2; data[4*i+1] = TCNT2; byte now =...
0
votes
2answers
47 views

TimerOne Hanging

For the following program. Compiles and runs. I start the Serial Monitor (shown following code) and it asks me to input the Blink Rate. This runs in setup. Then it enters the loop and prints to the ...
-1
votes
1answer
73 views

How to add another time counter to my functioning sketch?

I have a functional sketch that I run on an Arduino Uno, the output controlling a fan module; I need another timer to run a 2nd fan and I would like to use another output on the Uno to do that rather ...
0
votes
0answers
31 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 ...
0
votes
1answer
88 views

Arduino IDE with ATtiny85 error “multiple definition of `__vector_5”

I am having a problem compiling the code for my ATtiny85 circuit. I am using the timer/counter0 in normal mode so that when it overflows it triggers the TIMER0_OVF_vect ISR. When I have that ISR in ...
0
votes
3answers
71 views

ATmega328P - Problem using timer 2 for tone generation

I'm simply trying to use timer 2 for tone generation and what I get is a very faint and strange tone (almost like its modulated somehow as there is a "pulsing" to it). Here's my simple code: #include ...
0
votes
1answer
137 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 ...
1
vote
1answer
108 views

Having trouble figuring out CTC on Timer 1 with ATTiny85

I'm using Timer1 on the Attiny85 clocked at 1MHz to toggle an LED every 1 second. However, I'm having some issues regarding prescaler and OSC value selection. I'm using this formula, which I found in ...
0
votes
1answer
72 views

Can't get OC1B (pin 10) to output

I'm trying to get this program to use channel B for the output waveform using the phase correct PWM mode and using OCR1A as the top. With a 50% duty ratio I'm attempting to get a 10 Hz freq. I'm able ...
0
votes
2answers
297 views

Making a timer accurate to 1 millisecond possible? Using MAX7219 LED

I'm using the Max7219 (8 digits, 7bits) led display to try and make a timer. I have downloaded an example code from the following site to set the led digits: https://www.brainy-bits.com/arduino-...
0
votes
0answers
46 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 ...
1
vote
2answers
613 views

Converting human readable date to a unix timestamp [duplicate]

Can anyone provide a sample code that would convert a human readable date like 2019-10-27 22:10:35 to a unix timestamp like 1572214235? I found many topics about it, but they eider refer to out of ...

1
2 3 4 5
8