The Final Code
#include <TrueRandom.h> #include <VoiceShield.h>
//define input variables const int pinchPin = 31; const int rollPin = 32; const int tapPin = 33; const int twistPin = 34; const int shiftUpPin = 35; const int shiftDownPin = 38; const int shiftRightPin = 41; const int shiftLeftPin = 42;
//define output variables
const int speedadjuster = 28;
const int pinchLED = 22; const int rollLED = 23; const int tapLED = 24; const int twistLED = 25; const int shiftLED = 26;
const int speaker = 48;
//define notes
const float noteA = 55; const float noteB = 61.7354; const float noteC = 65.4064; const float noteD = 73.4162; const float noteE = 82.4069; const float noteF = 87.3071; const float noteG = 97.9989; const float nextnote = 110;
//define signal variables int given = 0; int gamespeed = 0; int initialgamespeed = 260; int needtoquitduetonoinputwithintimelimit = 0; int inputtimecountcheck = 0; int octaveselect = 0; int wanttoplaycountchecker = 0; int selection = 0; int playtimecount = 0; int quitplaytime = 0; int CorrectInputCount = 0; int MinimumGameSpeed = 1000; int ChangingGameSpeed = 5000; int GameSpeedDecriment = 100;
int trillDesire = 1; // music variables int noteDelay = 25; int trillDelay = 150; int PostNoteDelay = 20; int PostTrillDelay = 80; int timetoQuitMusicWait = 5000;
int SoundTestTime = 5000; int SoundTestCount = 0; //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Initialize the Voice shield // Allocate the memory into (240) 1-sec sections VoiceShield vs(240);
void setup() {
pinMode( pinchPin , INPUT ); pinMode( twistPin , INPUT ); pinMode( rollPin , INPUT ); pinMode( tapPin , INPUT ); pinMode( shiftUpPin , INPUT ); pinMode( shiftRightPin , INPUT ); pinMode( shiftDownPin , INPUT ); pinMode( shiftLeftPin , INPUT );
//pinMode( speedadjuster , INPUT );
pinMode( pinchLED , OUTPUT ); pinMode( rollLED , OUTPUT ); pinMode( tapLED , OUTPUT ); pinMode( twistLED , OUTPUT ); pinMode( shiftLED , OUTPUT );
//define output variables
digitalWrite( pinchLED , LOW ); digitalWrite( rollLED , LOW ); digitalWrite( tapLED , LOW ); digitalWrite( twistLED , LOW ); digitalWrite( shiftLED , LOW );
//analogWrite( speedadjuster , 0 ) ; analogWrite( speaker , LOW);
delay( 500 ); //start up delay
//Serial.begin(9600);
// Play "Hello" vs.ISDPLAY(51); delay(1000);
// start up light display!! or music!!
digitalWrite(tapLED, HIGH); //last command prior to void loop digitalWrite(pinchLED, HIGH); digitalWrite(twistLED, HIGH); // Press tap button for game. Press pinch buttons for music."
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void loop () {
if (HIGH == digitalRead(twistPin)) { digitalWrite(tapLED, LOW); //last command prior to void loop digitalWrite(pinchLED, LOW); digitalWrite(twistLED, LOW); InputSoundCoolness(); digitalWrite(tapLED, HIGH); //last command prior to void loop digitalWrite(pinchLED, HIGH); digitalWrite(twistLED, HIGH);
} if ( HIGH == digitalRead( pinchPin ) ) { //musical play mode selected
digitalWrite(shiftLED, HIGH); // turns on shift LED digitalWrite(tapLED, LOW); // turns off menu lights digitalWrite(pinchLED, LOW); digitalWrite(twistLED, LOW);
while ( quitplaytime == 0 ) {
octaveselect = octaveSELECT(digitalRead( tapPin ), digitalRead( rollPin )); // picks octave via the function at the bottom
PlayMusicNotes();
if ( playtimecount == timetoQuitMusicWait ) { //quits if user does not input a note quitplaytime = 1; playtimecount = 0; }
digitalWrite(tapLED, LOW); //turns off user lights digitalWrite(rollLED, LOW); digitalWrite(twistLED, LOW); }//end while digitalWrite(shiftLED, LOW); // turns off joystick LED quitplaytime = 0;
digitalWrite(tapLED, HIGH); // turns on menu lights digitalWrite(pinchLED, HIGH); digitalWrite(twistLED, HIGH); }//end music mode if
if ( HIGH == digitalRead( tapPin ) ) { //game mode selected
digitalWrite(tapLED, LOW); //turn menu LEDs off digitalWrite(pinchLED, LOW); digitalWrite(twistLED, LOW);
gamespeed = analogRead( speedadjuster ); // reads the speed selector input
delay( 500 ); int pastSelection = 0;
while ( needtoquitduetonoinputwithintimelimit == 0 ) { //game loop
selection = TrueRandom.random(5, 13); // this picks a random directive
given = 0;
PlayAudioDirective();
pastSelection = selection;
int whomp = 0;
while ( selection != whomp && inputtimecountcheck <= ChangingGameSpeed ) { //input loop
//set given GetUserInput(); whomp = CorrectInputSound(whomp);
delay(1); inputtimecountcheck++; //increments time count }
CheckForFunSoundBite();
if ( inputtimecountcheck > ChangingGameSpeed ) {
needtoquitduetonoinputwithintimelimit = 1; //checks to break break; }
if ( ChangingGameSpeed > MinimumGameSpeed ) { ChangingGameSpeed = ChangingGameSpeed - GameSpeedDecriment; }
}//end input loop
LowsLEDS();
given = 0;
inputtimecountcheck = 0; //resets timer
if ( needtoquitduetonoinputwithintimelimit == 1 ) { // if time is up then end sounds are played
// "You'll Get it next time" CorrectInputCount = 0; FailMusicClip(); vs.ISDPLAY(16); delay(750); vs.ISDPLAY(19); delay(1000); vs.ISDPLAY(79); delay(1);
} ChangingGameSpeed = 5000; needtoquitduetonoinputwithintimelimit = 0; digitalWrite(tapLED, HIGH); //turn menu LEDs on digitalWrite(pinchLED, HIGH); digitalWrite(twistLED, HIGH); }//end of game
//starts over == back to top }
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
int octaveSELECT(int TapState, int RollState) { int octave; if ( LOW == TapState && HIGH == RollState ) { octave = 8; //6 32 digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); } else if ( LOW == TapState && LOW == RollState ) { octave = 4; //5 16 digitalWrite(tapLED, LOW); digitalWrite(rollLED, LOW); } else if ( HIGH == TapState && LOW == RollState ) { octave = 2; //4 8 digitalWrite(tapLED, HIGH); digitalWrite(rollLED, LOW); } else if ( HIGH == TapState && HIGH == RollState ) { octave = 1; //3 4 digitalWrite(tapLED, HIGH); digitalWrite(rollLED, HIGH); } else { octave = 2; //4 8 digitalWrite(tapLED, HIGH); digitalWrite(rollLED, LOW); } return octave;
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void PlayMusicNotes() {
if ( (HIGH == digitalRead( shiftUpPin )) && (HIGH == digitalRead( shiftLeftPin )) ) { // plays notes based on octave and direction of joystick
playtimecount = 0; do { tone( speaker , noteA * octaveselect , noteDelay); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteA * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftUpPin ) && HIGH == digitalRead( shiftLeftPin ) );
} else if ( HIGH == digitalRead( shiftUpPin ) && LOW == digitalRead( shiftLeftPin ) && LOW == digitalRead( shiftRightPin ) ) {
playtimecount = 0; do { tone( speaker , noteB * octaveselect , noteDelay ); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteB * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftUpPin ) && LOW == digitalRead( shiftLeftPin ) && LOW == digitalRead( shiftRightPin ) ); // output note B
} else if ( HIGH == digitalRead( shiftUpPin ) && HIGH == digitalRead( shiftRightPin ) ) {
playtimecount = 0; do { tone( speaker, noteC * octaveselect , noteDelay ); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteC * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftUpPin ) && HIGH == digitalRead( shiftRightPin ) ); // output note C
} else if ( HIGH == digitalRead( shiftRightPin ) && LOW == digitalRead( shiftUpPin ) && LOW == digitalRead( shiftDownPin ) ) {
playtimecount = 0; do {
tone( speaker , noteD * octaveselect , noteDelay ); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteD * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftRightPin ) && LOW == digitalRead( shiftUpPin ) && LOW == digitalRead( shiftDownPin ) ); // output note D
} else if ( HIGH == digitalRead( shiftRightPin ) && HIGH == digitalRead( shiftDownPin ) ) {
playtimecount = 0; do { tone(speaker, noteE * octaveselect, noteDelay); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteE * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftRightPin ) && HIGH == digitalRead( shiftDownPin ) ); // output note E
} else if ( HIGH == digitalRead( shiftDownPin ) && LOW == digitalRead( shiftLeftPin ) && LOW == digitalRead( shiftRightPin ) ) {
playtimecount = 0; do { tone( speaker , noteF * octaveselect , noteDelay ); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteF * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftDownPin ) && LOW == digitalRead( shiftLeftPin ) && LOW == digitalRead( shiftRightPin ) ); // output note F
} else if ( HIGH == digitalRead( shiftDownPin ) && HIGH == digitalRead( shiftLeftPin ) ) {
playtimecount = 0; do {
tone( speaker, noteG * octaveselect , noteDelay ); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , noteG * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftDownPin ) && HIGH == digitalRead( shiftLeftPin ) ); // output note G
} else if ( HIGH == digitalRead( shiftLeftPin ) && LOW == digitalRead( shiftUpPin ) && LOW == digitalRead( shiftDownPin ) ) {
playtimecount = 0; do {
tone( speaker, nextnote * octaveselect , noteDelay ); delay(PostNoteDelay);
if (HIGH == digitalRead(twistPin) && 1 == trillDesire) { tone( speaker , nextnote * (octaveselect * 2) , trillDelay); digitalWrite(twistLED, HIGH); delay(PostTrillDelay); } digitalWrite(twistLED, LOW); } while ( HIGH == digitalRead( shiftLeftPin ) && LOW == digitalRead( shiftUpPin ) && LOW == digitalRead( shiftDownPin ) ); // output note G
}
else { // increments if no use of joystick delay( 1 ); playtimecount++; }
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void FailMusicClip() {
tone( speaker , noteA * 8, 200); delay(180); tone( speaker , noteB * 8, 200); delay(180); tone( speaker , noteG * 4, 200); delay(180); tone( speaker , noteG * 4, 200); delay(500); tone( speaker , noteA * 8, 200); delay(180); tone( speaker , noteB * 8, 200); delay(180); tone( speaker , noteG * 4, 200); delay(180); tone( speaker , noteG * 4, 200); delay(350); tone( speaker , noteD * 8, 250); delay(300); tone( speaker , noteE * 8, 500); delay(350); tone( speaker , noteG * 8, 550); delay(300); delay(1000);
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! int CorrectInputSound(int whomp) {
if ( selection == given) { // if correct input then this plays input sound
if ( selection == 5 || selection == 6 || selection == 7 || selection == 8) { digitalWrite( shiftLED , LOW ); SpecialJoyStickSound(); whomp = given; }
else if (selection == 9 ) { digitalWrite( tapLED , LOW ); vs.ISDPLAY(3); delay(500); vs.ISDPLAY(79); delay(1); whomp = given; }
else if (selection == 10) { digitalWrite( pinchLED , LOW ); vs.ISDPLAY(40); delay(1000); vs.ISDPLAY(79); delay(1); whomp = given; }
else if (selection == 11) { digitalWrite( rollLED , LOW ); vs.ISDPLAY(33); delay(700); vs.ISDPLAY(79); delay(1); whomp = given; }
else if ( selection == 12) { digitalWrite( twistLED , LOW ); vs.ISDPLAY(44); delay(500); vs.ISDPLAY(79); delay(500); whomp = given; } wanttoplaycountchecker = 0; // resets values inputtimecountcheck = 0; CorrectInputCount++; }
return whomp;
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void GetUserInput() {
if ( (digitalRead(shiftUpPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(shiftUpPin) == HIGH)) // this section of if statements recieves user input { given = 5; } else if ( (digitalRead(shiftRightPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(shiftRightPin) == HIGH)) { given = 7; } else if ( (digitalRead(shiftLeftPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(shiftLeftPin) == HIGH)) { given = 8 ; } else if ( (digitalRead(shiftDownPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(shiftDownPin) == HIGH)) { given = 6; } else if ( (digitalRead(pinchPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(pinchPin) == HIGH)) { given = 10; } else if ( digitalRead( rollPin ) == HIGH) { given = 11 ; } else if ( (digitalRead(tapPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(tapPin) == HIGH)) { given = 9; } else if ( (digitalRead(twistPin) == HIGH) || (digitalRead( rollPin ) == HIGH && digitalRead(twistPin) == HIGH)) { given = 12; }
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void PlayAudioDirective() {
if ( selection == 5) { // this section supplies audio of directive // "Up" vs.ISDPLAY(49); delay(1000); vs.ISDPLAY(79); delay(1); digitalWrite( shiftLED , HIGH ); }
else if ( selection == 6 ) { // " Down" vs.ISDPLAY(8); delay(550); vs.ISDPLAY(79); delay(1); digitalWrite( shiftLED , HIGH ); }
else if ( selection == 7 ) { // "Right" vs.ISDPLAY(46); delay(1000); vs.ISDPLAY(79); delay(1); digitalWrite( shiftLED , HIGH ); }
else if ( selection == 8 ) { // "Left" vs.ISDPLAY(22); delay(1000); vs.ISDPLAY(79); delay(1); digitalWrite( shiftLED , HIGH ); }
else if ( selection == 9) { // Bopit vs.ISDPLAY(2); delay(500); vs.ISDPLAY(79); delay(1); digitalWrite( tapLED , HIGH ); }
else if ( selection == 10) { //Squeezeit vs.ISDPLAY(35); delay(1000); vs.ISDPLAY(79); delay(1); digitalWrite( pinchLED , HIGH ); }
else if ( selection == 11) { // spin it vs.ISDPLAY(26); delay(700); vs.ISDPLAY(79); delay(1); digitalWrite( rollLED , HIGH ); }
else if ( selection == 12 ) { //Twist vs.ISDPLAY(42); delay(500); vs.ISDPLAY(79); delay(1); digitalWrite( twistLED , HIGH ); }
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void LowsLEDS() {
digitalWrite( tapLED , LOW ); digitalWrite( shiftLED , LOW ); digitalWrite( rollLED , LOW ); digitalWrite( twistLED , LOW ); digitalWrite( pinchLED , LOW );
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void SpecialJoyStickSound() {
tone(speaker, noteA * 8, 100);
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
void CheckForFunSoundBite() {
if (10 == CorrectInputCount) { digitalWrite(twistLED, HIGH); tone( speaker , 110 * 4 , 200); //A2 delay(250); digitalWrite(twistLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 4 , 100); //A2 delay(150); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 110 * 4 , 100); //A2 delay(150); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 123.47 * 4 , 200); //B2 delay(250); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 110 * 4 , 200); //A2 delay(250); digitalWrite(twistLED, LOW); } if (20 == CorrectInputCount) { digitalWrite(rollLED, HIGH); tone( speaker , 164.81 * 4 , 200); //E3 delay(250); digitalWrite(rollLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 174.61 * 4 , 200); //F3 delay(250); digitalWrite(shiftLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 196 * 4 , 200); //G3 delay(250); digitalWrite(twistLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 220 * 4 , 200); //A3 delay(250); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 246.94 * 4 , 200); //B3 delay(250); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 261.63 * 4 , 100); //C3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 246.94 * 4 , 100); //B3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 261.63 * 4 , 100); //C3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 246.94 * 4 , 100); //B3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 261.63 * 4 , 100); //C3 delay(150); digitalWrite(twistLED, LOW); } if (50 == CorrectInputCount) { digitalWrite(twistLED, HIGH); tone( speaker , 110 * 2 , 200); //A2 delay(250); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 146.83 * 2 , 200); //D3 delay(250); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 130.81 * 2 , 200); //C3 delay(250); digitalWrite(pinchLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(250); digitalWrite(rollLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 174.61 * 2 , 200); //F3 delay(250); digitalWrite(shiftLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 110 * 2 , 100); //A2 delay(150); digitalWrite(twistLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 123.47 * 2 , 100); //B2 delay(150); digitalWrite(rollLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 130.81 * 2 , 100); //C3 delay(150); digitalWrite(pinchLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 164.81 * 2 , 100); //E3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 174.61 * 2 , 100); //F3 delay(150); digitalWrite(shiftLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 196 * 2 , 100); //G3 delay(150); digitalWrite(rollLED, LOW);
} if (75 == CorrectInputCount) { digitalWrite(twistLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 100); //G3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 164.81 * 4 , 100); //E3 delay(150); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 100); //G3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 100); //G3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 164.81 * 4 , 100); //E3 delay(150); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 100); //G3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 100); //G3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 164.81 * 4 , 100); //E3 delay(150); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 100); //G3 delay(150); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(twistLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 146.83 * 2 , 100); //D3 delay(150); digitalWrite(twistLED, LOW); } if (99 == CorrectInputCount) { digitalWrite(twistLED, HIGH); tone( speaker , 130.81 * 2 , 800); //C3 delay(900); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 4 , 800); //C4 delay(900); digitalWrite(shiftLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 123.47 * 4 , 200); //B4 delay(300); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G2 delay(300); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 4 , 200); //A2 delay(300); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 123.47 * 4 , 400); //B2 delay(500); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 4 , 400); //C4 delay(500); digitalWrite(shiftLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 130.81 * 2 , 400); //C3 delay(500); digitalWrite(twistLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 4 , 400); //A2 delay(500); digitalWrite(pinchLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 800); //G3 delay(900); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 2 , 800); //A2 delay(900); digitalWrite(pinchLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 174.61 * 4 , 400); //F3 delay(500); digitalWrite(rollLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 164.81 * 4 , 400); //E3 delay(500); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 4 , 200); //C3 delay(300); digitalWrite(shiftLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 146.83 * 4 , 200); //D3 delay(300); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 164.81 * 4 , 200); //E3 delay(300); digitalWrite(twistLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 174.61 * 4 , 200); //F3 delay(300); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 146.83 * 4 , 400); //D3 delay(500); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 123.47 * 4 , 200); //B2 delay(300); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 4 , 200); //C4 delay(300); digitalWrite(shiftLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 146.83 * 4 , 200); //D3 delay(300); digitalWrite(rollLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 164.81 * 4 , 200); //E3 delay(300); digitalWrite(pinchLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 4 , 400); //C4 delay(500); digitalWrite(shiftLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 164.81 * 2 , 200); //E3 delay(300); digitalWrite(pinchLED, HIGH); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 164.81 * 2 , 200); //E3 delay(300); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 164.81 * 2 , 200); //E3 delay(300); digitalWrite(pinchLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300); digitalWrite(tapLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 164.81 * 2 , 200); //E3 delay(300); digitalWrite(twistLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300 + 50); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 185 * 2 , 200); //F#3 delay(300 + 25); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300 + 25); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 185 * 2 , 200); //F#3 delay(300 + 25); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300 + 25); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 185 * 2 , 200); //F#3 delay(300 + 25); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 2 , 200); //G3 delay(300 + 25); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 4 , 200); //A2 delay(300 + 25); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 123.47 * 4 , 200); //B2 delay(300 + 25); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 4 , 200); //C4 delay(300 + 25); digitalWrite(shiftLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 146.83 * 4 , 200); //D3 delay(300 + 25); digitalWrite(pinchLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 164.81 * 4 , 200); //E3 delay(300 + 25); digitalWrite(tapLED, LOW); digitalWrite(rollLED, HIGH); tone( speaker , 174.61 * 4 , 200); //F3 delay(300 + 25); digitalWrite(rollLED, LOW); digitalWrite(tapLED, HIGH); tone( speaker , 196 * 4 , 200); //G3 delay(300 + 25); digitalWrite(tapLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 8 , 200); //A3 delay(300); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 123.47 * 8 , 200); //B3 delay(300); digitalWrite(twistLED, LOW); digitalWrite(pinchLED, HIGH); tone( speaker , 110 * 8 , 200); //A3 delay(300); digitalWrite(pinchLED, LOW); digitalWrite(twistLED, HIGH); tone( speaker , 123.47 * 8 , 200); //B3 delay(300); digitalWrite(twistLED, LOW); digitalWrite(shiftLED, HIGH); tone( speaker , 130.81 * 8 , 200); //C4 delay(300 + 20); digitalWrite(shiftLED, LOW);
}
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! void InputSoundCoolness() {
while (SoundTestCount != SoundTestTime) { if ( HIGH == digitalRead(shiftUpPin) || HIGH == digitalRead(shiftDownPin) || HIGH == digitalRead(shiftLeftPin) || HIGH == digitalRead(shiftRightPin)) { SoundTestCount = 0; digitalWrite( shiftLED , HIGH ); SpecialJoyStickSound(); digitalWrite( shiftLED , LOW ); }
else if (HIGH == digitalRead(tapPin) ) { SoundTestCount = 0; digitalWrite( tapLED , HIGH ); vs.ISDPLAY(3); delay(500); vs.ISDPLAY(79); delay(1); digitalWrite( tapLED , LOW ); }
else if (HIGH == digitalRead(pinchPin)) { SoundTestCount = 0; digitalWrite( pinchLED , HIGH ); vs.ISDPLAY(40); delay(1000); vs.ISDPLAY(79); delay(1); digitalWrite( pinchLED , LOW); }
else if (HIGH == digitalRead(rollPin)) { SoundTestCount = 0; digitalWrite( rollLED , HIGH ); vs.ISDPLAY(33); delay(700); vs.ISDPLAY(79); delay(1); digitalWrite( rollLED , LOW ); }
else if ( HIGH == digitalRead(twistPin)) { SoundTestCount = 0; digitalWrite( twistLED , HIGH ); vs.ISDPLAY(44); delay(500); vs.ISDPLAY(79); delay(500); digitalWrite( twistLED , LOW ); } else { delay(1); SoundTestCount++; }
} SoundTestCount = 0;
} //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!