#include "SparkButton/SparkButton.h" #include "math.h" //Initialize Variables int i=2000; int Rlight; //Holds the value for the light that will turn on int check=0; //Variable to see if button was pressed on time int rate=2000; //Time the light will stay on in milliseconds int LastLight=0; //Variable to check what the last value of Rlight was SparkButton b = SparkButton(); //Standard setup for Sparkbutton void setup() { b.begin(); } void loop() { check=0; //Assign a Light number between 1 and 11 to Rlight Rlight=rand() % 11 + 1; //Checks to make sure a light is not illuminated twice in a row //and reassigns Rlight to a different value if this is the case for(i=0;i<100;i++) { if(Rlight==LastLight) { Rlight=rand() % 11 + 1; } else { i==101; } } LastLight=Rlight; //Turn on the randomly selected light with a random color scheme b.ledOn(Rlight, rand(), rand(), rand()); //Check to see if the button under lights 3, 6, or 9 was pressed //within the alotted amount of time. If it was pressed, cute the //amount of time to press the button and the amount of time a //light stays on by a small amount. if(Rlight==3) { for(i=0;i