Two Key Piano Bug Hunt! Test your Troubleshooting.

This code will run, but it has some unexpected behavior. Can you find the error without using the hint?

//Buggy: Beep a tone when you press button 2 on Code Piano, and a different tone for button 3 void setup(){ pinMode(10,OUTPUT); //Set speaker as an OUTPUT pinMode(2,OUTPUT); //Button 2 as an INPUT_PULLUP pinMode(3,INPUT_PULLUP); //Button 3 as an INPUT_PULLUP } void loop(){ if(digitalRead(2)==LOW){ //if button 2 is sending a low signal... tone(10,500); // a tone of 500 hertz on the speaker } else if(digitalRead(3)==LOW){ //if button 3 is sending a low signal... tone(10,600); // a tone of 600 hertz on the speaker } else{ //in all other cases (button is not sending a low signal)... noTone(10); //send a noTone command to the speaker } } // (c) 2018 Let's Start Coding. License:

Need a hint? Click here.