The goal of my whole project is to control (blink) a large amount of LEDs with my Arduino. I would be using 16 outputs to blink all my LEDs. I wouldn't have any problems, but all the codes I typed up have delays in them...and I have more than one blink pattern. I was hoping to add a push button to allow me to flip though them. Seeing how it wasn't going work out well I looked in to the Blink Without Delay. I was able get a fair understanding how the code is working.
But I'm having a very hard time figuring out how to add on to the code so I can blink multiple LEDs. Everything I look up on the web points back to the code on how to blink a single LED with out a delay. I've been running around in circles with this now for last three weeks. Could someone please show me an example on how to blink multiple LEDs with no delay.
Most of my codes I typed up before were dealing with half the LEDs on and the rest off till the other ones turn off. I guess an example on how to do that with Four LEDs (2xLEDs on 2xLEDs off back and forth) should be enough for me to work off of.
Thank you.
Code Im working with
const int ledPin = 13;
const int ledPin2 = 12;
const int ledPin3 = 10;
const int ledPin4 = 9;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
digitalWrite(ledPin, ledState);
}
}