//This is a sketch for the "Simon Says" project //using a shift register, LEDs, the random and //randomSeed functions. //globals int randomValue; //random value to be received from the random function int LEDValue =1; //value to correspond to the appropriate LED via the shift register int simonSays [50]; //Simon Says (original pattern) array int iSay [50]; //User Input array int iSaySpot = 0; //Current location of the user array //global buttons that correspond to the LEDs with button1 corresponding with the LED on the far right int btn1 = 11; int btn2 = 10; int btn3 = 9; int btn4 = 8; int btn5 = 6; int btn6 = 5; int btn7 = 4; int btn8 = 3; //globals for the shift register pins int serialIn = 30; int rclk = 32; int sclk = 34; int sclr = 36; boolean finalAnsState = false; //current state of if a final answer is being submitted int finalAnsB = 26; //final answer button to be pressed int count; //how long the orignal pattern should be void setup(){ //preparing the shift register pins pinMode(serialIn, OUTPUT); pinMode(rclk, OUTPUT); pinMode(sclk, OUTPUT); pinMode(sclr, OUTPUT); //preparing the buttons on the PmodBTNs pinMode(btn1, INPUT); pinMode(btn2, INPUT); pinMode(btn3, INPUT); pinMode(btn4, INPUT); pinMode(btn5, INPUT); pinMode(btn6, INPUT); pinMode(btn7, INPUT); pinMode(btn8, INPUT); //preparing the final answer button pinMode(finalAnsB, INPUT); //setting the shift register pins digitalWrite(serialIn, LOW); digitalWrite(rclk, LOW); digitalWrite(sclk, LOW); digitalWrite(sclr, LOW); //clearing out the registers digitalWrite(rclk, HIGH); digitalWrite(rclk, LOW); digitalWrite(sclr, HIGH); delay(500); count = 1; }//end of setup void loop(){ //resetting the arrays to all zeros for(int i=0; i<50; i++){ simonSays[i]= 0; iSay[i]= 0; } //loop to display an LED pattern of the approripate length for(int j=0; j