Hi! I'm a beginner in arduino and I'm having trouble with this code for make high and low 12 output one after one with millis. I have this code from @paulpaulson in this topic
this code (step 1 = light first 2 led, step 2 = light 2nd two, turn off first 2, etc.)
this code is good enough for me, but this code have just on interval time, I need 2 interval time in this code, one of them for onTime interval and one for offTime interval.
int ledPin9 = 9;
int ledPin8 = 8;
int ledPin7 = 7;
int ledPin6 = 6;
int ledPin5 = 5;
int ledPin4 = 4;
int ledPin3 = 3;
int ledPin2 = 2;
/// new
byte ledSequ [][8] {
{1, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 0, 0},
{0, 0, 0, 0, 0, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 1, 1},
};
// new
byte leds[] {ledPin2, ledPin3, ledPin4, ledPin5, ledPin6, ledPin7, ledPin8, ledPin9};
void setup()
{
Serial.begin(9600);
pinMode(ledPin9, OUTPUT);
pinMode(ledPin8, OUTPUT);
pinMode(ledPin7, OUTPUT);
pinMode(ledPin6, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop() {
const unsigned long blink = 1000;
static unsigned long blinkMillis;
if (millis() - blinkMillis >= blink ) {
static int nummer;
blinkMillis = millis();
Serial.println("blink");
for (unsigned int n=0; n<sizeof(leds); n++) digitalWrite(leds[n],ledSequ[nummer][n]);
nummer++;
nummer = nummer % (sizeof(ledSequ)/sizeof(leds));
}
}
can any body help me for edit this code for 12 outputs and 2 interval time, one interval for on time and one interval for off time.