Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int leds[] = {2,3,4,5,6,7,8,9,10}; // 9 total
- void setup(){
- for(int i = 0;i<90;i++){
- pinMode(leds[i],OUTPUT);
- }
- }
- void loop(){
- oneAtATime();
- //randomSequence();
- //topToBottom();
- }
- // Turns each LED off one at a time
- void oneAtATime(){
- for(int i = 0;i< 9;i++){
- digitalWrite(leds[i],HIGH);
- delay(100);
- digitalWrite(leds[i],LOW);
- }
- }
- // utterly random , a a kind of twinkling effect is acheived?
- void randomSequence(){
- int randomLed = random(0,9);
- digitalWrite(leds[randomLed],HIGH);
- delay(50);
- randomLed = random(0,9);
- digitalWrite(leds[randomLed],LOW);
- }
- // HOMEWORK: This one goes from top to bottom
- void topToBottom(){
- int d = 100;
- for(int i = 0;i< 5;i++){
- digitalWrite(leds[4-i],HIGH);
- digitalWrite(leds[4+i],HIGH);
- delay(d);
- digitalWrite(leds[4+i],LOW);
- digitalWrite(leds[4-i],LOW);
- delay(d);
- }
- for(int i = 4;i> 0;i--){
- digitalWrite(leds[4-i],HIGH);
- digitalWrite(leds[4+i],HIGH);
- delay(d);
- digitalWrite(leds[4+i],LOW);
- digitalWrite(leds[4-i],LOW);
- delay(d);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement