Go Down

Topic: Simultaneous Funtion/One-Shot Emulation (Read 562 times) previous topic - next topic

RFEngineer

Here's my dilemma:

I've written a program to quickly switch between receive and transmit states in a communications system.  The microprocessor is the Arduino Nano.  All is well until I want to pulse an LED as a one-shot for one second while the program continues to execute.  The LED will be used a visual fault indication, pulsed just long enough to show a system timing error.  And since this is a timing program with adjustable parameters changed in 1 msec increments, I cannot simply wait one second for the LED to turn off, then resume processing. 

What I want is (logically) simple: the ability to pulse an LED when an input pin changes state and stay that way for one second, while the program continues to execute.  Surely there must be some way of handling this with the Arduno microcontroller?

Ideas?  Thanks!

Paul 

dc42

Read and understand the Blink Without Delay example, then you will see how to program the Arduino to do several things at once.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Chaul

Maybe have an interrupt on changing of the input pin state that affects a global state variable. Then in the loop() function you'd set the ledPin HIGH or LOW accordingly. You can have the interrupt only trigger on HIGH, and then mark the time on another variable, and in the loop you would set it LOW after that time stamp is far enough in the past.

RFEngineer


Read and understand the Blink Without Delay example, then you will see how to program the Arduino to do several things at once.


dc42 & Chaul,

Thanks for your responses.  The "Blink without Delay" command should do the trick.  It's odd that the command does not appear in my Arduino programming book.

Paul

PaulS

Quote
It's odd that the command does not appear in my Arduino programming book.

Which one would that be?

RFEngineer


Quote
It's odd that the command does not appear in my Arduino programming book.

Which one would that be?


Monk, S., Programming Arduino - Getting Started with Sketches, ISBN 978-0-07-178422-1

Paul

Go Up