乒乓灯LED — Arduino Mega simulation

An interactive Arduino Mega circuit simulation you can run free in your browser on Velxio, by bxxbx.

Components

Sketch code

// Arduino Mega 2560 — Blink LED
#define PINNUM 8
const int PINLED[8]={6,7,8,9,10,11,12,13};
void setup() {
  for(int i=0;i<8;i++){
    pinMode(PINLED[i], OUTPUT);
  }

}

void loop() {
  for(int i=0;i<8;i++){
    digitalWrite(PINLED[i],HIGH);
    delay(1000);
    digitalWrite(PINLED[i],LOW);
    delay(500);
  }
  for(int i=7;i>=0;i--){
    digitalWrite(PINLED[i],HIGH);
    delay(1000);
    digitalWrite(PINLED[i],LOW);
    delay(500);
  }
}

More projects by bxxbx