Alternatives to timerdependant delays?


I'm doing a small project for my education in digital electronics system design and decided to make a simon says game on the arduino uno. It being an uno board it has the 328P on board. I decided to include a score counter by multiplexing a double 8-segment display. Since our project had to include interrupts I decided to use software interrupts by using timer2 and causing it to overflow at 1000hz.

My problem occured when I wanted my coloured leds lighting up during the game, however the LEDS have to be seen shining for a little while. I initially tried using the standard delay() but it seems that during the delay timer2 does not interrupt and thus my multiplex fail when other lights are supposed to be visible.

I tried implementing my own delay procedures by having a counter increased by the ISR and the delay method stays in a while-loop untill the counter has reached a certain value but it some how halts the multiplex anyway.

TLDR; Is there a way to delay the program without disrupting timer2 interrupts?

The BlinkWithoutDelay example in the IDE and/or maybe ?

OK it turns out it was just me being stupid ( as always). I had put the updating of the led outputs(digitalWrite) in the loop() part and the updating of their values in the ISR so when the delay occured, the ISR was still updating the values to be written to the leds but they were never written since the main loop was stuck in the delay. I moved the digitalWrites to the ISR and now it works :D

It is good practice to do as little as possible inside ISRs. Maybe set a volatile variable or two then react to the changes in the loop() function.

Yeah I guess.. I think a better solution would be to just update the values in the ISR as previously and make the loop run continuously somehow even when simons lights should stay lit for a while.

and make the loop run continuously [u]somehow[/u] even when simons lights [u]should stay lit for a while[/u].

This sounds like a job for timing using millis(). Did you look at the example and link I gave ?