ZDIRY-TUFWT-EBONM-EYJ00-IDBLANTER.COM
ZDIRY-TUFWT-EBONM-EYJ00
BLANTERWISDOM105

LED Chase using SimulIDE Arduino

Wednesday, May 16, 2018



Now I want to give a gift to my friend Shahil Bhatkar who has asked me how to make chase as much as 5 led. I made this program run using a simulator app called SimulIDE. You can download here.

Please use this program for your arduino:
//------------------------------------------------------------------------
// Program
//------------------------------------------------------------------------
byte ledPin [] = {9, 10, 11, 12, 13};   //Set pin for LED
int ledDelay   = 200;                   //set delay for chase
int direction  = 1;
int currentLed = 0;
unsigned long changeTime;

void setup() {
  for (int x = 0; x < 5; x++) {       //Set all pin as Output
    pinMode (ledPin[x], OUTPUT);
  }
  changeTime = millis();
}

void loop() {
  if ((millis() - changeTime) > ledDelay) {
    changeLED();
    changeTime = millis();
  }
}

void changeLED() {
  // turn off all LED's
  for (int x = 0; x < 5; x++) {
    digitalWrite(ledPin[x], LOW);
  }
  digitalWrite(ledPin[currentLed], HIGH);
  currentLed += direction;
  if (currentLed == 4) {
    direction = -1;
  }
  if (currentLed == 0) {
    direction = 1;
  }
}


Video:
Share This :
Prof. Apis

Hello Greetings all. I created this website to document the knowledge that I have learned. Also to help all friends. Suggestions and criticisms are very welcome to make this website better. Thank you

0 comments