Piano DJ Booth Bug Hunt! Test your Troubleshooting.

Sometimes the smallest bug can cause the biggest headache, especially when you have a large program. Don’t worry, you’re sure to find it! Just keep an eye on which pins do which functions in the program!

//Buggy: Each button on Piano activates a different sound effect void setup() { pinMode(10, OUTPUT); //speaker pinMode(2, INPUT_PULLUP); //button pinMode(3, INPUT_PULLUP); //button pinMode(4, INPUT_PULLUP); //button pinMode(5, INPUT_PULLUP); //button pinMode(6, INPUT_PULLUP); //button pinMode(7, INPUT_PULLUP); //button pinMode(8, INPUT_PULLUP); //button pinMode(9, INPUT_PULLUP); //button } void loop() { //rising pitch for (int i = 40; digitalRead(2)==LOW; i++) {//play tones 0-1199 tone(10, i); delay(3); } //random tones if(digitalRead(3)==LOW) { tone(10, random(1,1201)); //Play any tone between 0 and 1200 delay(50); //a new tone every 50 milliseconds } //falling pitch for (int i = 1300; digitalRead(4)==LOW; i--) {//play tones from 1300 down to 31 tone(10, i); delay(3); } //three pitches rising together for(int i=100; digitalRead(5)==LOW;i++){ //for a duration of 300 loops (400-100)... tone(10,i); //play a tone equal to i- this will rise from 100 to 399 delay(10); tone(10,i*2); //play a tone of i*2, range of 200 to 799 delay(10); tone(10,i*4); //play a tone of i*4, range of 400 to 1599 delay(10); } int lowTone = 10; //starting place for a rising tone int highTone = 1800; //starting place for a sinking tone //Low pitch rises as high pitch falls while(digitalRead(6)==LOW){ //While button 6 is pressed, ignore the rest of the void loop tone(10,lowTone); //Play the 'lowTone' variable value, which starts at 10 delay(50); tone(10,highTone); //Play highTone, which starts at 1800 delay(50); highTone-=10;// subtract 10 from highTone lowTone+=10; // add 10 to lowTone //reset the tones if(highTone < 10){ //Keeps highTone from going below 0 highTone = 1500; } if(lowTone > 1800){ //Keeps lowTone from going out of earshot lowTone = 10; } } //Create a steady low beat if(digitalRead(7)==LOW){ tone(10,50); delay(250); noTone(10); delay(250); } //A beat that speeds up from 10 times a second to 1000 times per second for(int i=100; digitalRead(8)==LOW; i--){ tone(10,200); delay(i); noTone(10); delay(i); } //A high-pitched beat if(digitalRead(9)==LOW){ tone(10,950); delay(150); noTone(10); delay(150); } noTone(2); //Stops any tones from any buttons at the end of each loop. } // (c) 2018 Let's Start Coding. License: www.letsstartcoding.com/bsdlicense

Need a hint? Click here.