LED delay off with milli()


the led blinky quite easy how can done switch off after on second.

code: [select]

void led(int val) {
  unsigned long currentmillis = millis();
  if (currentmillis - previousmillis >= val)
  {
    digitalwrite(led, high);
    previousmillis = currentmillis;
  }
}

void loop()
{
  led(600);
}



here i've created function , called within loop. way call several times like

code: [select]

void loop();
{
  led (100)
  led(1000);
  led(600);


would above approach best

digitalwrite(led, high);
change to
digitalwrite(led, !(digitalread(led)); // toggles led


Arduino Forum > Using Arduino > Project Guidance > LED delay off with milli()


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'