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
1answer
357 views

Port Manipulation and serial communication

i'm working on a laser timer using arduino and i saw that using direct port manipulation can have a really better time precision. My only concern is about serial communication, because i am using some ...
0
votes
2answers
196 views

Hardware damage from executing tight polling loop over extended periods of time?

I want my project to be standing by at the ready for months and years at a time, so I started writing my code to throttle back from polling at delayMicroseconds to just delay. Like, after 15 minutes ...
0
votes
0answers
137 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
1answer
5k views

Using timer0 on Arduino Uno

I am trying to find a simple timer0 interrupt example, but none of those work. Neither this code which I tried to run: boolean toggle0 =0; void setup() { pinMode(8, OUTPUT); cli(); // Set ...
0
votes
1answer
133 views

Software PWM implementation on ATTiny44 screws up timing functions

I've came up with a poor man's implementation of software-based PWM for the ATTINY44 and I'm kinda stuck now. It works but it screws up the timing functions badly (delay, delayMicroseconds) no matter ...
2
votes
3answers
5k views

How to run a timer every 12 hours (exceeding the max size of int) without an RTC?

I'm experimenting with a Nano, and trying to trigger an action around twice a day. I'm aware that it's not super accurate, but I don't really mind, as long as it's in the ballpark. I've tried using ...
1
vote
3answers
1k views

Traffic lights using timer

My traffic light code for the Arduino doesn't run. I was wondering if anyone could point out where my issues lie. The red and green LEDs should be on for 15 seconds and the amber on for 5 seconds. #...
0
votes
1answer
270 views

How accurate the an attiny timer function

I have an AT-Tiny (trinket) and I want to trigger LED on for 30 seconds every 24 hours. I'm using the timer library as follows timer.setInterval(86400000, toggleit()); void toggleit() { ...
9
votes
4answers
2k views

Turn Arduino on with timer every 24h

I'm currently working on an Arduino project that sends the charge of my car battery once a day via an ESP8266 to me. During the winter I don't drive my car, and I would like to get informed when the ...
1
vote
2answers
127 views

Using bitRead to toggle between LEDs [closed]

How can I use bitRead() to toggle between 3 LEDs? I have 3 LEDs - red, green, blue - and I have these 4 stages: Red ON and green, blue OFF Green ON and red, blue OFF Blue ON and red, green OFF All ...
2
votes
0answers
460 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 ...
0
votes
2answers
1k views

Using Arduino to detect when a sensor is on and off and display time elapsed

I would like to know if I can use a pressure sensor with an Arduino. The code will detect when the sensor is on, will start a timer, stop when the sensor is off, and display the time elapsed. Here is ...
3
votes
2answers
1k views

Timer2 “Clear OC2B on Compare Match” not working as expected in CTC mode

This is a follow up to my previous question. I have Timer2 in CTC mode, with TOP=OCR2A set to 150 (with a prescaler of 8, giving a 75us timing interval). The datasheet states that setting COM2B1 to ...
3
votes
2answers
635 views

Can a timer be used in both CTC and (fast) PWM mode simultaneously?

I would like to generate a sequence of pulses of varying lengths in the range of 0-100us, so that from the start of one pulse to the start of the next there is a delay of 100us. I have set up timer0 ...
2
votes
1answer
2k views

Attiny85 code on Attiny84

I made OLED timer/watch using Attiny85, but as internal clock isnt accurate i need external crystal. On Attiny85 im short on pins so i am switching to Attiny84 but i have problems to compile/upload ...
5
votes
1answer
331 views

Help managing the fallout from timer0 mode and prescaler change on ATMega2560 without modifying wiring.c

For a driving application I need the PWM mode to be phase correct and the prescaler to be 1. The issue is that the board I am working with has the load hooked up to a PWM pin reliant on timer0. The ...
3
votes
1answer
4k views

Comparing time_t values within an if statement

I am using an UNO with a RTC to control a light board. I'm using a simple control structure to decide when to turn things off and on. It's my understanding that a time_t value is just a number (number ...
7
votes
3answers
2k views

Write PWM with only 8 bit? (Timer2)

I have a problem with the Servo library. I need to read a PPM signal and create a PWM signal of each channel. The problem is that PPM has a higher resolution than PWM so I want to use the 16 bit ...
1
vote
0answers
121 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
1answer
180 views

Having trouble using RTC if I set an ISR for a 1 second timer

I built a sketch using some timer ISR code to get a trigger every second. (for the Atmega328 chip I use the following code I got form the internets. It works) It runs fine and I get a trigger/...
0
votes
3answers
456 views

Time.h rollover after 49.7 days [duplicate]

I'm developing a arduino based system, which includes a alarm system. Searching on the Internet, I found these lybraries "Time.h" and "TimeAlarms.h". In the requirements, it says: "Time does not ...
1
vote
2answers
1k views

Proper Attiny85 timer/delay

Im having problems with Attiny85 programming. I am making something similar like this project. But i added function that every day on some time it turns on output - something like alarm clock. The ...
1
vote
1answer
243 views

How do I use two PulseIn() functions simultaneously in Arduino?

I want to connect multiple Ultrasonic sensors to my Arduino board. For that, I need multiple pulseIn() functions to work at the same time. How can I do that?
1
vote
0answers
502 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 ...
2
votes
2answers
178 views

How can i do something like multi threathing in arduino?

I am checking for ways to implement multi threathing in Arduino, I have also tried using the library TimerOne but it doesn't seem to work, what I'm trying to make is an Arduino application then, every ...
5
votes
1answer
234 views

Is there a portable timer interrupt library?

I have a need for timer interrupt (for the sake of this exercise - say I need to execute something every second) I found code in many places on the internets that does this using ISR for 328/Uno. (...
-1
votes
2answers
598 views

Using arduino uno as a battery charger timer

My question is, can I use a Arduino as a battery charger timer, I have a 3.7 v 1200 mah lithium battery that I have been charging with a 4.2 450 ma charger for quite some time, I normally just use ...
0
votes
2answers
138 views

Sketch does not work without delay() or other complex functions like digitalWrite()

I have a simple sketch here that should just blink a led once a second or so (approximately): boolean onOff=true; int count=0; void setup() { pinMode(13, OUTPUT); } void loop() { count++; ...
1
vote
1answer
124 views

How come my code does not wait for a specific time before going into an if statement?

I have an HC-SR04 attached to a servo. When the 90 degree reading is less than 30 cm, I want the motor to take 2 seconds to turn to 130 degrees, get a measurement on the right, and turn back to 90 ...
0
votes
2answers
43 views

Follow up question to Calling a timer when a button is pushed

I have changed the code with some help here. There are two buttons each one is set to turn on a LED. When the LED turns on it is timed and when the time is up it turns off. The problem I am having is ...
1
vote
2answers
880 views

calling a timer when a button is pushed

I'm trying to call a function to keep an LED on for a certain amount of time. The function is called when the button is pushed but the LED stays on. I used the same code in the void loop before moving ...
0
votes
1answer
4k views

Stepper Motor Button Press

I am having difficulties programming what should be a simple sketch that gets my stepper motor to run at one step per second indefinitely at the press of a button and then stops at the press of ...
1
vote
1answer
4k views

WDT & Software RESET in ESP8266 + Arduino IDE

I am working on ESP8266 in Arduino IDE. I want to know how to Software RESET the ESP8266. Any sketch/example would be useful. Moreover, how to initialise WDT in ESP8266. Kindly help!
0
votes
1answer
971 views

Why does servo library conflict with irremote?

I am building an Arduino Mega robot. I am planning to use IRremote.h library for it. I am using multiple libraries in my code and I do not know which timers are taken. I always get errors when ...
0
votes
1answer
5k views

NodeMCU Arduino set PWM Frequency to specific frequency

I am using NodeMCU and I program it using Arduino IDE, I need to change the PWM frequency of a port, in Arduino I used to change the frequency using timers registers like that: TCCR1B = (TCCR1B & ...
0
votes
1answer
1k views

Arduino PWM fading led in assembly

I'm writing Arduino UNO (=ATMega328P-PU) programs in assembly to save memory, so I use avra.exe (same as atmel studio's avrasm32) to compile and avrdude to upload, and simple programs like blinking ...
2
votes
1answer
1k views

Uno timer 2 set up

I am trying to use Timer2 in an Uno in fast PWM mode. Can someone explain how to set up the TCCR2A & B registers? Currently I have: TCCR2A |= _BV(WGM21) | _BV(WGM20); TCCR2B &= ~_BV(...
1
vote
2answers
131 views

What is the difference between running code with the scope of the void setup() or void loop() vs. outside their scope?

Good evening everyone, I have bene playing around with making my own library, specifically for the controlling Timer1 on the Arduino Mega 2560. I'm sort of new to OOP but I am trying my hand at it ...
0
votes
1answer
497 views

use more then one timer

I'm working on Arduino uno and trying to use more then one timer. I'm using timer1 for my software watchdog (I needed bigger interval for that, so my program won't reset itself after 8 seconds). In ...
1
vote
7answers
2k views

How accurate is arduino time keeping?

I want to use my arduino to turn a light off for 16 hours and on for 8 hours. I know the general code, just using delays and the relay shield code as well. I want to know how accurate this will be? ( ...
2
votes
1answer
472 views

How to user timer interrupts for times longer than can TNCTx can keep track of?

I am trying to program my Arduino Mega 2560 to effectively create a PWM signal on any digital pin using timer interrupts and timer1. The pins will pulse a finite amount of times (not indefinitely). I ...
2
votes
2answers
1k views

How do I use interrupt service routines inside libraries and classes?

I'm trying to have a millis() timer run to emulate a hardware timer inside a library, but I'm having issues compiling the code. I want the callback (pseudo ISR) to be part of the class, and not use ...
3
votes
1answer
800 views

Setting the frequency of a timer interrupt

The concept: Play a sine wave saved as a character array in PROGMEM through an 8-bit DAC connected to the PORTC pins on the Arduino Mega. This works: // File just defines an array and a size #...
0
votes
2answers
2k views

Arduino: Sending SD CSV file online at specific time of the day

I intend to perform data logging from sensors and store it on SD card as CSV format. The data is related to weather and I would like to send it at the end of the day/ Any available codes how to deploy ...
0
votes
1answer
1k views

Button Relay Control

How can I fix this sketch to make it so that once the button is pressed, it performs some action for a certain amount of time and then returns back to a low state until it is pressed again. For ...
1
vote
1answer
797 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 ...
0
votes
1answer
502 views

Why is timer0 the fastest timer in the arduino?

In the documentation, it shows that the higher frequency that can be reached with an Arduino UNO for and 8bits PWM is using timer0 with the pre-scaler set at 1. That gives a Fs of 62500 Hz, but ...
1
vote
2answers
343 views

How to monitor a sensor for specific period

As noted in earlier posts, I am building a model railroad crossing gate signal, complete with gate arms, flashers and sound. Although I haven't settled on exactly how I am going to implement detection ...
0
votes
0answers
442 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 ...
1
vote
2answers
745 views

Reading two sensors at different frequencies… multiple Timer3?

Originally, I had a single sensor which I was reading at 100MHz. I used Timer3 and function attached to it to do both reading and writing of the sensor data (print to com port). Now I have added ...

1
3 4
5
6 7