I am trying to modify the Blinkw/o Delay program.
But what i want isnt working quite right:
i want leds to light in this pattern:
o
oo
ooo
oooo
ooooo
o
oo
ooo
oooo
ooooo
-etc.
THIS IS MY CODE:
const int ledPin = 31;
const int ledPinA = 33;
const int ledPinB = 35;
const int ledPinC = 37;
const int ledPinD = 39;
const int ledPinE = 41;
const int ledPinF = 43;
const int ledPinG = 45;
const int ledPinH = 47;
const int ledPinJ = 49;
const int ledPinK = 51;
const int ledPinL = 53;
int ledState = LOW;
int ledStateA = LOW;
int ledStateB = LOW;
int ledStateC = LOW;
int ledStateD = LOW;
int ledStateE = LOW;
int ledStateF = LOW;
int ledStateG = LOW;
int ledStateH = LOW;
int ledStateJ = LOW;
int ledStateK = LOW;
int ledStateL = LOW;
long previousMillis = 0;
long interval = 200;
long previousMillisA = 0;
long intervalA = 400;
long previousMillisB = 0;
long intervalB = 600;
long previousMillisC = 0;
long intervalC = 800;
long previousMillisD = 0;
long intervalD = 1000;
long previousMillisE = 0;
long intervalE = 1200;
long previousMillisF = 0;
long intervalF = 1400;
long previousMillisG = 0;
long intervalG = 1600;
long previousMillisH = 0;
long intervalH = 1800;
long previousMillisJ = 0;
long intervalJ = 2000;
long previousMillisK = 0;
long intervalK = 2200;
long previousMillisL = 0;
long intervalL = 2400;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(ledPinA, OUTPUT);
pinMode(ledPinB, OUTPUT);
pinMode(ledPinC, OUTPUT);
pinMode(ledPinD, OUTPUT);
pinMode(ledPinE, OUTPUT);
pinMode(ledPinF, OUTPUT);
pinMode(ledPinG, OUTPUT);
pinMode(ledPinH, OUTPUT);
pinMode(ledPinJ, OUTPUT);
pinMode(ledPinK, OUTPUT);
pinMode(ledPinL, OUTPUT);
}
void loop()
{
unsigned long currentMillis = millis();
unsigned long currentMillisA = millis();
unsigned long currentMillisB = millis();
unsigned long currentMillisC = millis();
unsigned long currentMillisD = millis();
unsigned long currentMillisE = millis();
unsigned long currentMillisF = millis();
unsigned long currentMillisG = millis();
unsigned long currentMillisH = millis();
unsigned long currentMillisJ = millis();
unsigned long currentMillisK = millis();
unsigned long currentMillisL = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
digitalWrite(ledPin, ledState);
if(currentMillisA - previousMillisA > intervalA) {
// save the last time you blinked the LED
previousMillisA = currentMillisA;
// if the LED is off turn it on and vice-versa:
if (ledStateA == LOW)
ledStateA = HIGH;
else
ledStateA = LOW;
digitalWrite(ledPinA, ledStateA);
}{
if(currentMillisB - previousMillisB > intervalB) {
// save the last time you blinked the LED
previousMillisB = currentMillisB;
// if the LED is off turn it on and vice-versa:
if (ledStateB == LOW)
ledStateB = HIGH;
else
ledStateB = LOW;
digitalWrite(ledPinB, ledStateB);
}{
if(currentMillisC - previousMillisC > intervalC) {
// save the last time you blinked the LED
previousMillisC = currentMillisC;
// if the LED is off turn it on and vice-versa:
if (ledStateC == LOW)
ledStateC = HIGH;
else
ledStateC = LOW;
digitalWrite(ledPinC, ledStateC);
}{
if(currentMillisD - previousMillisD > intervalD) {
// save the last time you blinked the LED
previousMillisD = currentMillisD;
// if the LED is off turn it on and vice-versa:
if (ledStateD == LOW)
ledStateD = HIGH;
else
ledStateD = LOW;
digitalWrite(ledPinD, ledStateD);
}{
if(currentMillisE - previousMillisE > intervalE) {
// save the last time you blinked the LED
previousMillisE = currentMillisE;
// if the LED is off turn it on and vice-versa:
if (ledStateE == LOW)
ledStateE = HIGH;
else
ledStateE = LOW;
digitalWrite(ledPinE, ledStateE);
}{
if(currentMillisF - previousMillisF > intervalF) {
// save the last time you blinked the LED
previousMillisF = currentMillisF;
// if the LED is off turn it on and vice-versa:
if (ledStateF == LOW)
ledStateF = HIGH;
else
ledStateF = LOW;
digitalWrite(ledPinF, ledStateF);
}{
if(currentMillisG - previousMillisG > intervalG) {
// save the last time you blinked the LED
previousMillisG = currentMillisG;
// if the LED is off turn it on and vice-versa:
if (ledStateG == LOW)
ledStateG = HIGH;
else
ledStateG = LOW;
digitalWrite(ledPinG, ledStateG);
}{
if(currentMillisH - previousMillisH > intervalH) {
// save the last time you blinked the LED
previousMillisH = currentMillisH;
// if the LED is off turn it on and vice-versa:
if (ledStateH == LOW)
ledStateH = HIGH;
else
ledStateH = LOW;
digitalWrite(ledPinH, ledStateH);
}{
if(currentMillisJ - previousMillisJ > intervalJ) {
// save the last time you blinked the LED
previousMillisJ = currentMillisJ;
// if the LED is off turn it on and vice-versa:
if (ledStateJ == LOW)
ledStateJ = HIGH;
else
ledStateJ = LOW;
digitalWrite(ledPinJ, ledStateJ);
}{
if(currentMillisK - previousMillisK > intervalK) {
// save the last time you blinked the LED
previousMillisK = currentMillisK;
// if the LED is off turn it on and vice-versa:
if (ledStateK == LOW)
ledStateK = HIGH;
else
ledStateK = LOW;
digitalWrite(ledPinK, ledStateK);
}
{
if(currentMillisL - previousMillisL > intervalL) {
// save the last time you blinked the LED
previousMillisL = currentMillisL;
// if the LED is off turn it on and vice-versa:
if (ledStateL == LOW)
ledStateL = HIGH;
else
ledStateL = LOW;
digitalWrite(ledPinL, ledStateL);
}
}
}
}
}
}
}
}
}
}
}
}
}
what's happening looks more like an 8-bit counter than a steady incremental sequence.
Any words of wisdom?
THANKS!
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.