Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 26th, 2014  |  syntax: C  |  size: 0.58 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. int leds[5] = {13, 12, 11, 10, 9};
  2. int buttons[5] = {8, 7, 6, 5, 4};
  3. int niveau = 0;
  4. int ledList[32];
  5.  
  6. void setup() {
  7.         for(int i = 0; i<5;i++){
  8.                 pinMode(leds[i], OUTPUT);
  9.                 pinMode(buttons[i],INPUT); //Initializing button as input
  10.                 digitalWrite(buttons[i],HIGH); //Enabling the internal Arduino pullup-resistor
  11.         }
  12. }
  13. void ledSequence()
  14. {
  15.         for(int i=0; i<=niveau; i++)
  16.         {
  17.                 digitalWrite(ledList[i + 8],HIGH);
  18.                 delay(1000);
  19.                 digitalWrite(ledList[i + 8],LOW);
  20.                 delay(1000);
  21.         }
  22. }
  23. void loop()
  24. {
  25.         ledList[niveau] = random(1 , 5);
  26.         ledSequence();
  27.         delay(2000);
  28.         niveau++;
  29. }
clone this paste RAW Paste Data