Interactive Mashrabia – Lilach Raz_Adi Levy_Yafit Zvulun

Interactive Mashrabia Wall by Lilach Raz_Adi Levy_Yafit Zvulun from ruth ron on Vimeo.

תרגיל בית ל-28/3/12 5LED_PATTERN

//5 LEDs are connected to Arduino pins: 5,6,7,8,9

// the code will light 5 LEDs one after the other and then turn LEDs off one after the other

//creating a list [] that contains the pin numbers

int ledPins[] = {5,6,7,8,9}; //global variables, can be read from every function

void setup(){

  for (int i=0; i<5; i++ ) {    //'i' if a local variable inside the "for" command

  pinMode(ledPins[i], OUTPUT);

  }

}

void loop(){

  int delayTime; // 'delayTime' is a local variable inside 'loop' function

 delayTime = 100;

  for (int j=0; j<5; j++ ) {

  digitalWrite(ledPins[j],HIGH);

  delay (delayTime);

  }

  delayTime = 500;

   for (int n=0; n<5; n++ ) {

  digitalWrite(ledPins[n],LOW);

  delay (delayTime);

  }

}