Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

array

int ledArray[] = {2,3,4,5,6,7,8,9};

int delayTime = 50;

void setup() {
  //initialise ledArray as outputs
  for(int i = 0; i<10; i++)
  {
    pinMode(ledArray[i], OUTPUT);
  }
}

void loop() {
  //turn LEDs on from 0-7
  for(int i = 0; i <= 7; i++)
  {
    digitalWrite(ledArray[i], HIGH);
    delay(delayTime);
  }

  //turn LEDs off from 7-0
  for(int i = 7; i >= 0; i--)
  {
    digitalWrite(ledArray[i], LOW);
    delay(delayTime*5);
  }
}
Source by core-electronics.com.au #
 
PREVIOUS NEXT
Tagged: #array
ADD COMMENT
Topic
Name
9+8 =