Need Help With Count and millis


hi, trying write code turn led lights on , off millis. cannot use blink without delay sample because intervals different.

here's code wrote.

code: [select]
int led = 42;
int led2 = 44;
int led3 = 46;
int led4 = 48;
int led5 = 50;
int led6 = 52;

int total = 1580;

int count = 0;

void setup() {
  pinmode(led, output);
  digitalwrite(led, low);

  pinmode(led2, output);
  digitalwrite(led2, low);

  pinmode(led3, output);
  digitalwrite(led3, low);

  pinmode(led4, output);
  digitalwrite(led4, low);

  pinmode(led5, output);
  digitalwrite(led5, low);

  pinmode(led6, output);
  digitalwrite(led6, low);
}

void loop() {
 
  if(millis() == total*count + 200) {
    digitalwrite(led, high);
  }

  if(millis() == total*count + 350) {
    digitalwrite(led2, high);
  }

  if(millis() == total*count + 550) {
    digitalwrite(led3, high);
  }
 
  if(millis() == total*count + 630) {
    digitalwrite(led4, high);
  }

  if(millis() == total*count + 830) {
    digitalwrite(led5, high);
  }

  if(millis() == total*count + 880) {
    digitalwrite(led6, high);
  }

  if(millis() == total*count + 1080) {
    digitalwrite(led6, low);
  }

  if(millis() == total*count + 1180) {
    digitalwrite(led5, low);
  }

  if(millis() == total*count + 1280) {
    digitalwrite(led4, low);
  }

  if(millis() == total*count + 1380) {
    digitalwrite(led3, low);
  }

  if(millis() == total*count + 1480) {
    digitalwrite(led2, low);
  }

  if(millis() == total*count + 1580) {
    digitalwrite(led, low);
  }

 count = count + 1;
}


without last line "count = count + 1;" led lights turn on loop once, understand why.  last line led lights won't turn on @ all. can please tell me i'm doing wrong? using count++; same thing.

also imagine if leave on long count big unsigned long.  in actuality won't know how can resolve that?

thank you!

quote
i cannot use blink without delay sample because intervals different.
i can make led(s) flash @ different times, different on , off intervals, using blink without delay philosophy. could, too, if understood doing. isn't rocket science.

you expecting exact values when subtract value current time. not realistic assumption. should perform action when interval greater or equal desired value, not when interval desired value.


Arduino Forum > Using Arduino > Programming Questions > Need Help With Count and millis


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts