- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
Ten LED flashing project 2Arduino Uno - 01330 Ohm Resistors - 10Led - 10Breadboard - 01Jumper Wires
Arduino Sketch
int timer = 250; // Wait for 250 millisecond(s)int ledPins[] = {0,1,2,3,4,5,6,7,8,9}; // an array of pin numbers to which LEDs are attachedint pinCount = 10; // Number of pinsvoid setup(){ // Function is called when sketch start for (int thispin = 0; thispin <pinCount;thispin++){ // use a pin 0 to 9 as an output loop pinMode(ledPins[thispin],OUTPUT); }}void loop(){ for (int thispin = 0; thispin <pinCount;thispin++){ // loop from the lowest pin to the highest digitalWrite(ledPins[thispin],HIGH); // LED on delay(timer); // Wait for 250 millisecond(s) digitalWrite(ledPins[thispin],LOW); // LED Off } for (int thispin = pinCount - 1;thispin >= 0;thispin--){ // loop from the highest pin to the lowest digitalWrite(ledPins[thispin],HIGH); // LED On delay(timer); // Wait for 250 millisecond(s) digitalWrite(ledPins[thispin],LOW); // LED Off }}
int timer = 250; // Wait for 250 millisecond(s)
int ledPins[] = {0,1,2,3,4,5,6,7,8,9}; // an array of pin numbers to which LEDs are attached
int pinCount = 10; // Number of pins
void setup(){ // Function is called when sketch start
for (int thispin = 0; thispin <pinCount;thispin++){ // use a pin 0 to 9 as an output loop
pinMode(ledPins[thispin],OUTPUT);
}
}
void loop(){
for (int thispin = 0; thispin <pinCount;thispin++){ // loop from the lowest pin to the highest
digitalWrite(ledPins[thispin],HIGH); // LED on
delay(timer); // Wait for 250 millisecond(s)
digitalWrite(ledPins[thispin],LOW); // LED Off
}
for (int thispin = pinCount - 1;thispin >= 0;thispin--){ // loop from the highest pin to the lowest
digitalWrite(ledPins[thispin],HIGH); // LED On
delay(timer); // Wait for 250 millisecond(s)
digitalWrite(ledPins[thispin],LOW); // LED Off
}
}
Comments
Post a Comment