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

Valutazione Template - Joomla! Forum - community, help and support

SD Datastring Convention

First use of Arduino Uno : avrdude error on Blink uploading