Led sequence without delay

Hi

Bit new to arduino but been getting on well and loving arduino. Having one issue tho, wanting to make a midi sequencer with led running in a line indicating when the midi notes are triggered with a total of 8 leds. I've got the sequence working with a shift register to run the leds. I also have got 8 buttons to turn the notes and leds off.

The only issue I'm having is I'm using a delay between the led's changing to get the right tempo and step between the led sequence but when I have the delay in it stops the buttons from turning the midi notes off. As I understand it delay basically tells the arduino to do nothing for that period of time. So I'm just wondering whether there away around this. So that my buttons will work while the led's shift along the line.

I'll post my code tomorrow, I'm on my phone at the moment.

I've seen other sequencer projects so i thought there would be away.

Thanks

Slightlygrim

This comes up about ten times a day. See the blink without delay sketch in your IDE for an example of a finite state machine. This will tell you more:- http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html

I didn't understand mucho the proyect but I've worked many times without delays because it's not efficient. You may use millis(), or Timer0 or Timer1. I suggest the use of timers because the microcontroller works less and you dont need the main loop(), main loop wastes a lot of computing.

Regards.

I suggest the use of timers because the microcontroller works less and you dont need the main loop(), main loop wastes a lot of computing.

This is incorrect advice, in fact as it stands it doesn't make much sense at all.

The micro controller does not work more or less, it is working at a constant rate, this is not a laptop you know.

The main loop does not waste computing power, that is just a silly statement. The processor is always going to be running, it has to do something when it is not doing anything useful, so it is best to have it just checking if it is time to do the next useful thing.

mart256: main loop wastes a lot of computing.

Its not possible to have the Arduino do nothing. It might as well waste its time in loop() as anywhere else.

I wrote a demo sketch in this Thread that illustrates the use of the techniques of Blink Without Delay and State variables in a more extensive example.

There is also a very extensive thread about led sequences here.

...R

Grumpy_Mike:

I suggest the use of timers because the microcontroller works less and you dont need the main loop(), main loop wastes a lot of computing.

This is incorrect advice, in fact as it stands it doesn't make much sense at all.

The micro controller does not work more or less, it is working at a constant rate, this is not a laptop you know.

The main loop does not waste computing power, that is just a silly statement. The processor is always going to be running, it has to do something when it is not doing anything useful, so it is best to have it just checking if it is time to do the next useful thing.

Well, I didn't know that smart ass.

To the OP, avoid using delay(), just use millis() or timers.

Regards.

Well, I didn't know that smart ass.

I wonder what one is "that"? So many things you appear not to know.

This is not your typical "blind leading the blind" forum, if you make a mistake be prepared to be corrected. I consider that comment "personal abuse", please do not do it again.

Ok I stepped out of the line with that words I know, but they way you corrected was not friendly either. Next time please avoid using “silly” or doing ironic comparations (“not a laptop you know”).

Martin.

I don't think that "silly" is an unreasonable response to the suggestions in Reply #2. Maybe you don't like being contradicted, but if you're in the habit of posting that sort of advice I think it will become a familiar experience.