Juan Carlos
Published © LGPL

Driving LEDs

Easy way to connect leds to Udoo Neo or any arduino board.

BeginnerFull instructions provided1 hour1,532
Driving LEDs

Things used in this project

Hardware components

UDOO NEO
UDOO NEO
×1

Story

Read more

Schematics

ULN2803

connecting a few leds :)

Check the polarity of the components !!!!!

Code

Arduino array

Arduino
This code declares a few leds, and puts them in an array. Afterwards it lights on and off the different leds.
int timer = 1000;        
int ledPins[] = { 
   5,6,7,8, 9, 10,11, 12 };       // an array of pin numbers to which LEDs are attached
int pinCount = 8;           // the number of pins (i.e. the length of the array)

void setup() {
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++)  {
    pinMode(ledPins[thisPin], OUTPUT);      
  }
}

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) { 
    digitalWrite(ledPins[thisPin], HIGH);   
    delay(timer);                  
    digitalWrite(ledPins[thisPin], LOW);    

  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) { 
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    digitalWrite(ledPins[thisPin], LOW);
  }
}

Credits

Juan Carlos

Juan Carlos

8 projects • 9 followers

Comments