document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. int timer = 100; // The higher the number, the slower the timing.
  2. int ledPins[] = {
  3. 2, 3,4,5,6,7,8,9 }; // an array of pin numbers to which LEDs are attached
  4. int pinCount = 8; // the number of pins (i.e. the length of the array)
  5.  
  6. int buttonPin = A5;
  7. int buttonPin2 = A4; // variable for reading the pushbutton status
  8.  
  9. // variables will change:
  10. int buttonState=0; // variable for reading the dip switch status
  11. int buttonState2=0; // variable for reading the dip switch status
  12.  
  13. void setup() {
  14. int thisPin;
  15. // the array elements are numbered from 0 to (pinCount - 1).
  16. // use a for loop to initialize each pin as an output:
  17. for (int thisPin = 0; thisPin < pinCount; thisPin++) {
  18. pinMode(ledPins[thisPin], OUTPUT);
  19. }
  20. pinMode(buttonPin,INPUT);
  21. pinMode(buttonPin2,INPUT);
  22. }
  23.  
  24. void loop() {
  25. // read the state of the pushbutton value:
  26. buttonState = digitalRead(buttonPin);
  27. buttonState2 = digitalRead(buttonPin2);
  28.  
  29. // check if the dip switch is pressed.
  30. // if it is, the buttonState is HIGH:
  31. if(buttonState==HIGH && buttonState2==HIGH){
  32. // loop from the lowest pin to the highest:
  33. for (int thisPin = 0; thisPin < pinCount; thisPin++) {
  34. // turn the pin on:
  35. digitalWrite(ledPins[thisPin], HIGH);
  36. delay(timer);
  37. // turn the pin off:
  38. digitalWrite(ledPins[thisPin], LOW);
  39. }
  40.  
  41. // loop from the highest pin to the lowest:
  42. for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
  43. // turn the pin on:
  44. digitalWrite(ledPins[thisPin], HIGH);
  45. delay(timer);
  46. // turn the pin off:
  47. digitalWrite(ledPins[thisPin], LOW);
  48. }
  49. }
  50.  
  51. }
');