Questions tagged [timing]

This tag is for questions about timing code execution, or external events.

Filter by
Sorted by
Tagged with
0
votes
2answers
37 views

Timing taking longer than expected

This is on a custom Arduino PCB (32u4) that I am programming with a Sparkfun Pocket AVR Programmer. A different program that I was writing wasn't working the way I expected it to, so I tried the "...
1
vote
1answer
94 views

Can I get some help with a metronome code on my arduino uno?

ok so I dont actually know anything about coding or electronics outside of being an electrician. This is something i've been working on for about a month. I may be asking something dumb but here it is....
0
votes
4answers
84 views

When GPS can't see satellites, how can I continue to tick off a smooth-ish time?

I'm getting 10 updates/sec from my GPS unit (The MTK3339 used in the Adafruit breakout board), and using it to update a clock display. This works well enough, though there's one minor problem that I'd ...
-1
votes
1answer
45 views

Does DmxSerial stops interrupts?

I am trying to build a setup with an Arduino Mega, having a DMX output (using DMXSimple library), and a MIDI library (to be done). I was wondering, if I get into problems. According to This question, ...
0
votes
1answer
58 views

Arduino timer to turn a serve at a certain time

i am working on a project for my school tech class. Our goal is to make a vehicle that will travel along a cable and drop an egg to a target while going down the cable. i am using an arduino to to ...
-1
votes
1answer
409 views

Handling overflow in micros() [duplicate]

The documentation for micros() says: Returns the number of microseconds since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately ...
-1
votes
1answer
149 views

Using mills() in place of delay() on relays not getting solid switch over

I know I should post some code that maybe cleaner but really I am just in need of a answer to a problem I seem to run into a lot when using mills() in place of delay(), whilst making a Christmas light ...
1
vote
1answer
404 views

How to randomize the delay in Arduino Stepper code?

How does one add a random DELAY between 10 and 20 seconds? For example in the following stepper logic I have a delay of 11 seconds - expressed in milliseconds as: delay(11000). What would I need to ...
0
votes
1answer
56 views

Measuring lenght of time light levels peak using photoresistor

I'm trying to measure shutter speeds on old cameras. This essentially consists of: Shining a torch at one end of the camera putting the photoresistor at the other end trigger the shutter which ...
0
votes
1answer
600 views

Strange discrete errors when reading HC-SR04 sonar sensor

I'm experimenting with an HC-SR04 sonar sensor. Basically I'm measuring the distance to a cardboard box twice a second with these lines of code running on an ESP32: unsigned long sonarMeasure() { ...
1
vote
1answer
156 views

Atmega328P Prescaler to Microseconds

For a bitbanging project I'm working on, I need to measure microseconds as accurately as possible. The function micros() won't work for me here because of the unpredictable times at which it might ...
8
votes
4answers
1k views

delay(time); vs if(millis()-previous>time); and drift

Going through an old project, I had code on two Arduino Due that looked like this void loop() { foo(); delay(time); } taking to heart the majority of literature on using delay(); I recoded this ...
2
votes
4answers
6k views

Use timer0 without affecting millis() and micros()

I'm writing a library which needs an ISR to turn off an LED some time after it was turned on. Since it's all about turning an LED on and off it doesn't need to be very precise. On the other hand I ...
1
vote
3answers
93 views

Arduino not recognizing when a timer reaches 0

Alright, so I'm attempting to make a timer that will turn on a light after an hour. Currently I have it set to 5 seconds for testing. What is happening is whenever I start the program it won't ...
0
votes
3answers
2k views

Arduino Blink two LEDs without Delay(amount of repetitions)

Arduino community. I have had experience with Arduino for 3 years now and have finally come to the conclusion to get rid of the delay function entirely. Below is the code to blink two LEDs a ...
0
votes
1answer
217 views

Arduino, Receiving Instant Time When Event Occurs [closed]

i am trying to figure out situation that i have mentioned about in the topic. I am trying to get an event's time when it occurs. For example, i am trying to receive Diagnostic Port's data by Arduino ...
2
votes
3answers
808 views

Control time without delay() Arduino

For the last couple of day I've been trying and failed many times just to not use the delay() funtion in Arduino. I have to admitted that my coding skill are extremely bad. What i trying to do is: If ...
0
votes
2answers
107 views

Buffering output stream

I'm looking to toggle a pin on and off in a fast and timing-sensitive manner, and I'm wondering if the Arduino Uno has any built in "buffers" that would be able to hold a set of values and send them ...
1
vote
1answer
58 views

Carry out two consecutive tasks when a button is pressed

I'm building a project that has 2 motors. What I want to do is: When button is pressed (hold down through RF controller) then: Run motor A on pwm at 50 for 1 second Run motor B on pwm at 255 for 1 ...
0
votes
2answers
178 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 ...
3
votes
3answers
653 views

Ensuring specific frequency at specific time?

I, at the moment am trying to come up with a simple way where I can program an Arduino to provide a step signal with a given frequency, at a specific time. The frequency has to be ramped up, and ...
0
votes
2answers
130 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
2k views

analogRead() takes >400 us on Arduino Zero but ~100 us on Uno, why?

I've been trying to figure out why the analogRead() function takes about four times as long on an Arduino Zero than on an Uno, when the Zero has a faster clock than the Uno. Arduinos website says ...
1
vote
1answer
670 views

Force compiler to execute instructions sequentially?

Is there a way to force the Arduino compiler to compile individual commands sequentially? Looking at the disassembly, lines of the assembly code for different C/Arduino commands are mixed. I was ...
0
votes
1answer
43 views

Why doesn't the time update?

I am making an arduino clock/alarm. I use an LCD screen to display the time. void loop(){ static unsigned long timing=micros(); if (mode == 0) {//mode 0 is when the time should show ...
5
votes
1answer
953 views

Syncing/taking external clock for SPI on Arduino Due

I have an Arduino Due with a SAM3X8E chip and am trying to read SPI data from an external source that is communicating in SPI. I was able to get data by identifying specific bytes that are identifiers ...
2
votes
2answers
3k views

How to update multiple outputs simultaneously

I need to update simultaneously all the outputs of a specific port. I am familiar with using micro-processors assembly language. After initializing a port (Data Direction Register), I can write to ...
1
vote
1answer
841 views

Should millis() be stored in a variable once each loop, or called for every reference?

When comparing the value of millis() numerous times per loop(), are there reasons for/against storing it in a variable once at the top of loop(), v.s. calling millis() each time? The most basic ...
0
votes
2answers
389 views

Delay function broken?

I noticed timing inconsistencies in my project, and further debugging pinpointed it to the problem below. The text should be updating every second, but the returned values are >> 1000ms. To clarify, ...
1
vote
0answers
67 views

Multi-drop RS485 device control v1.0 - why is limit for “TIME_BETWEEN_MESSAGES ”?

I am going to use Nick's rolling-master system library (http://www.gammon.com.au/forum/?id=11428) in my home project. For first experiments and testing, I have: - BAUD_RATE = 9600 - max adress = 2 (...
1
vote
2answers
1k views

Hardware Interrupt Triggered Randomly

So there is this pretty generic part of my project that involves triggering an ISR that will flip a boolean value. I have set up the software side like so: void setup() { attachInterrupt(...
2
votes
2answers
108 views

How to make 2 LEDs flash in a 5/4 Polyrhythm?

Basically I want one LED to flash 5 times in the same amount of time it takes another LED to flash 4 times. This is what I have, but they are flashing independently and I need them to flash ...
0
votes
3answers
1k views

Turning on led every half hour

How can I make my program so that every half hour LED lights on and work for 5 minutes and than go off and the process should repeat I made code but it does not works. Can someone help me? void ...
0
votes
4answers
377 views

Altering code to run a timer while checking for a data input

I am rather new to the Arduino world and am looking for a way to create my own tipping rain gauge with only one Arduino(micro). I have had some help from a friend to get a loop that checks for when a ...
0
votes
1answer
29 views

Verifying the timing between relay activations

I would like to verify timings of a relay controlled by an arduino (uno R3). There is a lot going on in the sketch and it does not use the delay function but one which is based on counting ...
0
votes
2answers
2k views

bi-directional nrf24 communication

The central arduino The 1st node The 2nd node I want the central to send to the first node the rgb code like a string on the loop "rgb: 255000255" but when it detects something to PIR to send a ...
0
votes
2answers
138 views

Problem using Ino build for 8 MHz

I want to use the Ino command line toolkit to build and upload my HEXes. It works well for the regular Arduino, however when I try to upload code to a Mini Pro 3.3V at 8 MHz, the code has the timing ...
0
votes
2answers
489 views

How to upgrade Arduino UnoR3 clock

A little background: I need to generate a 40KHz frequency as accurately as possible. (One of my other posts is here: Stable frequency generation) My code is solid- I'm using an Uno R3 and ...
0
votes
2answers
605 views

How do I send an IR signal from an Arduino

I want to send a generic (not Sony, etc.) remote's signal from my Arduino. I have already used a IR decoder program to capture the timing of the signal: int IRsignal[] = { // ON, OFF (in 10's of ...
1
vote
4answers
762 views

How can I run two Arduinos in sync for video generation?

I was thinking about building a video circuit that uses two Arduinos (maybe more) to generate video using NTSC and the AD725. Although, VGA might be nice if possible. Anyway, the idea is to use one ...
2
votes
2answers
1k views

How to wait outside the loop without delay()?

Is it possible to delay a task inside a function that is called only once (meaning, it's not inside the loop) without using delay()? This library I'm using, for reading sensor measurements via ...
0
votes
1answer
756 views

PWM pins weird on Arduino Mega, works on Arduino Uno

I've bought one of those cheap 2.4" TFT LCD resistive touchscreens, one of these: It works great on my Arduino Uno, using the code from this github repository. Now I'm trying to get this to work on ...
-1
votes
1answer
154 views

Lily Pad mp3, nested loops with timing and play randomly choosen mp3, coding problem

The best way to explain my problem is in form of code... const int ringerPin = A0; const int offhook = A4; const int onhook = A5; void setup(){ pinMode(ringerPin, OUTPUT); ...
1
vote
2answers
1k views

Arduino time(milli) and pressure sensor

I've succeeded to get an Arduino to work with a pressure sensor. What I want to do is when I put pressure on the sensor, after 5 minutes the led lights on. it starts over again if there's no ...
2
votes
2answers
193 views

Replicate a Waveform Exactly with An Arduino Uno

So I've got a waveform that's high for 16ms and low for 2ms repeating forever. I need to recreate that and offsets of that waveform time exactly on a different pin. Right now, I've got an interrupt on ...
8
votes
2answers
9k views

How precise is the timing of pulseIn()?

I've been using the pulseIn() function for processing PWM-based binary data encoding. It works well for distinguishing pulses which are significantly different lengths, e.g. 500us vs. 1500us. That ...