English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have 5 led light patterns, and what i need is one switch that when you press it, the first pattern will be the output, then press, and 2nd pattern, press, 3rd pattern, and so on.

Do i have to use interrupts?
help.

thank you and Godbless.

2007-09-13 01:45:42 · 1 answers · asked by asker123 2 in Computers & Internet Programming & Design

1 answers

Nope.... In a loop, you can check for the switch input. If the switch is pressed, you can display the pattern. You'd only use interrupts if the checks for the switch closure cannot be placed inside the loop or immediate response to the switch is required regardless of where the code might be executing at every moment.

An interrupt will cause your code to jump to the vector regardless. It is not always necessary.

I'd do something like:

loop:
sw := switchstatus
if (sw = closed) then
display LED
end if
end loop

2007-09-13 01:56:21 · answer #1 · answered by tkquestion 7 · 0 0

fedest.com, questions and answers