0% found this document useful (0 votes)
67 views

Arduino LED Lab.

This document contains code for an Arduino project that uses 10 LEDs connected to pins 4 through 13 to light up in sequence. The setup routine initializes the LED pins as outputs and starts the timing. The loop routine runs the changeLED subroutine to turn off the current LED and light the next one when the delay time has passed, changing direction at the ends. It identifies 4 group members for the 4SE-BSEE class.

Uploaded by

Jonathan Brylle
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views

Arduino LED Lab.

This document contains code for an Arduino project that uses 10 LEDs connected to pins 4 through 13 to light up in sequence. The setup routine initializes the LED pins as outputs and starts the timing. The loop routine runs the changeLED subroutine to turn off the current LED and light the next one when the delay time has passed, changing direction at the ends. It identifies 4 group members for the 4SE-BSEE class.

Uploaded by

Jonathan Brylle
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Members: 4SE-BSEE

Fidelino, Dale R.
Pilar, Melvin M.
Cardinal, Jonathan F.

// the loop routine runs over and over


again forever:
void loop() {
if ((millis() - changeTime) >
ledDelay) {

byte ledPin[] =
{4,5,6,7,8,9,10,11,12,13};

changeLED();

int ledDelay(65);
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
changeTime = millis();
}
}
// the setup routine runs once when
you press reset:
void setup() {
for (int x=0; x<10; x++) {
pinMode(ledPin[x], OUTPUT); }
changeTime = millis();
}
4SE-BSEE

void changeLED() {
for (int x=0; x<10; x++) {
digitalWrite(ledPin[x],LOW);
}
digitalWrite(ledPin[currentLED], HIGH);
currentLED += direction;
if (currentLED == 9)
{direction = -1;}
if (currentLED == 0)
{direction = 1;}
}

You might also like