Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }
- }
- /*
- * setup() - this function runs once when you turn your Arduino on
- * We the three control pins to outputs
- */
- void setup() {
- for(int i = 0; i < NUMPINS; i++)
- pinMode(ledPins[i],OUTPUT);
- // pinMode(buttonPin, INPUT);
- Serial.begin(115200);
- }
- /* Declare an array of function pointers and statically
- * assign all the functions to it.
- */
- static void (*functions[])(void) = {
- oneAfterAnotherLoop,
- oneOnAtATime,
- inAndOut,
- cylonScan,
- randomized,
- progression1,
- progression2,
- progression3,
- progression4,
- progression5,
- progression6,
- };
- #define NUMFUNCS (sizeof(functions)/sizeof(functions[0]))
- /*
- * loop() - this function will start after setup finishes and then repeat
- * we call a function called oneAfterAnother(). if you would like a different behaviour
- * uncomment (delete the two slashes) one of the other lines
- */
- void loop() {
- // Reset the LED with a brief all on all off flash
- delay(500);
- allOnOff();
- delay(500);
- // Do the new function
- functions[state]();
- // update the function pointer off set for next time.
- state=(state+1)%NUMFUNCS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement