top of page

Control 12 LEDs without a Shift Register-Arduino


SOURCE CODE:

const int led1 = 2; const int led2 = 3; const int led3 = 4; const int led4 = 5; const int led5 = 6; const int led6 = 7; const int led7 = 8; const int led8 = 9; const int led9 = 10; const int led10 = 11; const int led11 = 12; const int led12 = 13;

int ledArray[12] = { led1, led2, led3, led4, led5, led6, led7, led8, led9, led10, led11, led12};

void setup() {

}

void loop() {

int index; int delayTime = 100; // time (milliseconds) to pause between LEDs // make this smaller for faster switching // step through the LEDs, from 0 to 7 for(index = 0; index <= 13; index++) { digitalWrite(index, HIGH); // turn LED on delay(delayTime); // pause to slow down the sequence digitalWrite(index, LOW); // turn LED off } for(index = 13; index >= 0; index--) { digitalWrite(index, HIGH); // turn LED on delay(delayTime); // pause to slow down the sequence digitalWrite(index, LOW); // turn LED off } delay(1000);


Single post: Blog_Single_Post_Widget
bottom of page