Arrch:
medic29:
I'm not sure it is the case of them being turned on/off quickly when they turn on like they are supposed toIt is, I can see it in the logic.
if(currentMillis - previousMillis > ledFOn){
digitalWrite(ledFPin, HIGH);
}
...
if(currentMillis - previousMillis > ledAOn){
digitalWrite (ledBPin, LOW);
digitalWrite (ledAPin, LOW);
digitalWrite(ledCPin, LOW);
digitalWrite(ledDPin, LOW);
digitalWrite(ledEPin, LOW);
digitalWrite(ledFPin, LOW);
}
If these two if statements fire in the same loop iteration, there will be rapid on/offs. Plug in the value of 2.3 seconds (for current minus previous) and tell me if they both will fire.
Woo Hoo!!!
I got it to work the way I want it to. If someone could check the code to see if you see any issues? I will then be working on the button code probably tomorrow. Here is the code that works:
// test code utilizing blink without delay.
// written 11/13/12.
const int ledAPin = 7; // the number of the LED pin
const int ledBPin = 8; // the number of the 2nd LED pin
const int ledCPin = 9; // the number of the 3rd LED pin
const int ledDPin = 10; // the number of the 4th LED pin
const int ledEPin = 11; // the number of the 5th LED pin
const int ledFPin = 12; // the number of the 6th LED pin
// Variables will change:
long previousMillis = 0; // will store last time LED was updated
long ledAOn = 2500; // total time ledA is on
long ledBOn = 300; // the time ledB will come on
long ledBOff = 1700; // the time ledB goes off
long ledCOn = 600;
long ledCOff = 1400;
long ledDOn = 900;
long ledDOff = 1100;
long ledEOn = 1200;
long ledEOff = 800;
long ledFOn = 1500;
long ledFOff = 500;
long totalTime = 3000; // the total time for the sequence
void setup() {
// set the digital pin as output:
pinMode(ledAPin, OUTPUT);
pinMode(ledBPin, OUTPUT);
pinMode(ledCPin, OUTPUT);
pinMode(ledDPin, OUTPUT);
pinMode(ledEPin, OUTPUT);
pinMode(ledFPin, OUTPUT);
}
void loop()
{
unsigned long currentMillis = 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;
//
// // set the LED with the ledState of the variable:
// digitalWrite(ledPin, ledState);
if(currentMillis - previousMillis > totalTime) {
previousMillis = currentMillis;
}
if(currentMillis - previousMillis > ledFOn){
if(currentMillis - previousMillis < ledAOn)
digitalWrite(ledFPin, HIGH);
}
if(currentMillis - previousMillis > ledEOn){
if(currentMillis - previousMillis < ledAOn)
digitalWrite(ledEPin, HIGH);
}
if(currentMillis - previousMillis > ledDOn){
if(currentMillis - previousMillis < ledAOn)
digitalWrite(ledDPin, HIGH);
}
if(currentMillis - previousMillis > ledCOn){
if(currentMillis - previousMillis < ledAOn)
digitalWrite(ledCPin, HIGH);
}
if(currentMillis - previousMillis > ledBOn){
if(currentMillis - previousMillis < ledAOn)
digitalWrite(ledBPin, HIGH);
}
if(currentMillis - previousMillis < ledAOn){
digitalWrite (ledAPin, HIGH);
}
if(currentMillis - previousMillis > ledAOn){
digitalWrite (ledBPin, LOW);
digitalWrite (ledAPin, LOW);
digitalWrite(ledCPin, LOW);
digitalWrite(ledDPin, LOW);
digitalWrite(ledEPin, LOW);
digitalWrite(ledFPin, LOW);
}
if(currentMillis - previousMillis > totalTime) {
previousMillis = currentMillis;
}
}
Awesome....thanks again.