Advertisement
phil_s_stein

circ02, expanded

Jul 31st, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1.     }
  2. }
  3.  
  4. /*
  5.  * setup() - this function runs once when you turn your Arduino on
  6.  * We the three control pins to outputs
  7.  */
  8. void setup() {
  9.     for(int i = 0; i < NUMPINS; i++)
  10.         pinMode(ledPins[i],OUTPUT);
  11.     // pinMode(buttonPin, INPUT);
  12.  
  13.     Serial.begin(115200);
  14. }
  15.  
  16. /* Declare an array of function pointers and statically
  17.  * assign all the functions to it.
  18.  */
  19. static void (*functions[])(void) = {
  20.     oneAfterAnotherLoop,
  21.     oneOnAtATime,
  22.     inAndOut,
  23.     cylonScan,
  24.     randomized,
  25.     progression1,
  26.     progression2,
  27.     progression3,
  28.     progression4,
  29.     progression5,
  30.     progression6,
  31. };
  32. #define NUMFUNCS (sizeof(functions)/sizeof(functions[0]))
  33.  
  34. /*
  35.  * loop() - this function will start after setup finishes and then repeat
  36.  * we call a function called oneAfterAnother(). if you would like a different behaviour
  37.  * uncomment (delete the two slashes) one of the other lines
  38.  */
  39. void loop() {
  40.     // Reset the LED with a brief all on all off flash
  41.     delay(500);
  42.     allOnOff();
  43.     delay(500);
  44.  
  45.     // Do the new function
  46.     functions[state]();
  47.  
  48.     // update the function pointer off set for next time.
  49.     state=(state+1)%NUMFUNCS;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement