Go Down

Topic: Question about the external Interrupt ?? (Read 730 times) previous topic - next topic

Mashadawy

Hello there,
I was thinking... because I cant use delay into an Interrupt function why not calling a function e.g. "MyDelay" into the interrupt function !!
is that possible, and If it is, and another external interrupt happened while "MyDelay" is not yet finished, will "MyDelay" function start allover again from zero, or the interrupt will be denied !!

actually what I need to do is simply as pressing a button "as an external interrupt" that light up a LED for 30 seconds and if I repressed the button before the 30 seconds passed it repeat those 30 seconds again.

please I need Help on that cuz I am newbie on the arduino programing.
regards,
Mashad.

PaulS

Quote
please I need Help on that cuz I am newbie on the arduino programing.

Then you should not be using interrupts. Poll the pin, instead.

Mashadawy

actually it is not that simple, cuz I am going to replace the button with a sensor so the Interrupt is caused by a sensor that has a critical function, and I will not be able to poll the pin.

AWOL

Why don't you tell us what you want to do, not how you think you should do it?
Try not to use the abbreviation "cuz"
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Mashadawy

okay... sorry :)

this is what I exactly trying to do is to drive a robot inside a circle of a black tape when a line sensor detects the black line, then it should move backward to the center of the circle.. the program has a lot of processing from other sensors, so I cant use polling and I'm afraid I might miss the line.

so any ideas ?!

AWOL

How broad is the tape, and how fast is the object moving?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Mashadawy

the tape is about 1 cm wide, and I am not quite sure about the speed of the driving motors..

MarkT

You can guarantee that polling will work if you have an interrupt routine that just sets a flag - then you poll for the flag.  However slow the polling it will eventually spot that something happened because the polling code is the only code that will clear the flag.

If you put delays into an interrupt routine you will hold up the entire system which will lead to all sorts of problems - keep interrupt handlers to the minimum - pass off any heavy lifting to loop().
[ I won't respond to messages, use the forum please ]

Mashadawy

thank you very much MarkT, it really helped :)

Go Up