Hi friends,
I am making use of the switch to blink a single LED.It is working good
But in my board ,it consists of 8 switches and 8 leds . when I press first switch,first LED have to blink.when I press second switch,second LED have to blink.and so on can anybody give me the code for this program.I have worked on different patterns but only one LED is blinking
For a LED to blink you need atleast a 500 ms delay between ON and OFF values. So, if you use delays then button press detection will not work and so you have to use a 500 ms timer interrupt and then use a switch statement and based on the case of the switch the particular LED is blinked.
I'm a friend of interrupts. Especially with scanning multilpe switches and controlling multiple Leds.
But you can do without interrupts.
Just run a loop and include a 20ms wait.
Inside th loop use a counter, incremented every loop. If counter =25, then toogle LED and set counter =0
This gives an about 1Hz blinking frequency.
But they can become intimidating to some one who has not yet got the basics firmly in place. And with nested interrupts, it can quickly become a nightmare.
But polling is also useful- when the processes were slow- printers in DOS used polling- it was awe-inspiring!
The use of the goto command, although available in C language, is totally inadvisable because it breaks the progam structure, turning more complicated to analyse the code working.