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
1
vote
1answer
21 views

IMU (MPU9250) and Ticker on ESP32

I want to read the data from an IMU (MPU9250) periodically. To do that I use a ticker as shown in the following code: #include <Ticker.h> #include "MPU9250.h" constexpr int ...
3
votes
1answer
180 views

Measure audio frequency through pulse duration

Hello dear StackExchange users, i want to develop an Infrared blaster which i can plug into the headphone jack of a phone or console of choice. In order to communicate what frequency to modulate the ...
0
votes
0answers
29 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 ...
2
votes
1answer
21 views

Serial doesent work when calling function from timer

You can try the code on your arduino UNO to better understand what is hapening in serial monitor! I want to calculate jacobian matrix from rotation matrix! float jakMATB[3][3] = { {0, 0, 0}, {0, 0, 0},...
4
votes
1answer
86 views

Arduino timer interrupts for PID

I'm working on a robotics project where an arduino nano is acting as the motion controller. I'm trying to use a trapezoidal motion profile generator and PID loop to follow that profile, but I found ...
1
vote
1answer
45 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
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 ...
0
votes
2answers
81 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
1answer
45 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
29 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 ...
2
votes
2answers
283 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
156 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 ...
2
votes
1answer
32 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
2answers
65 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
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. ...
2
votes
1answer
41 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> ...
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
0answers
31 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
25 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/...
1
vote
1answer
37 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
31 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
68 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
135 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
48 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
19 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
92 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
124 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
75 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
43 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
84 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
73 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
86 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
132 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
58 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
48 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 ...
0
votes
1answer
81 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
52 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
93 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
38 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
131 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
97 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
59 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
193 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
33 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
3answers
203 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
227 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
608 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
243 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 ...

1
2 3 4 5
8