30 Ocak 2016 Cumartesi

Led Karaşimşek :)

Kızım ve oğlum Ardiuno ile tanıştı :)




Kod:

int timer = 100;
int ledPins[] = {
  2, 3, 4, 5, 6, 7
};
int pinCount = 6;


void setup() {
  for (int thisPins = 0; thisPins < pinCount; thisPins++) {
    pinMode(ledPins[thisPins], OUTPUT);
  }
}


void loop() {
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    digitalWrite(ledPins[thisPin], LOW);
  }
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    digitalWrite(ledPins[thisPin], LOW);
  }
}