#define NOTE_C4 262 //From pitches.h file defined in [Arduino Tone Tutorial][1]
int Key = 2;
int KeyVal = 0;
byte speaker = 12;
void setup()
{
pinMode(Key, INPUT); //Declare our key (button) as input
pinMode(speaker, OUTPUT);
}
void loop()
{
KeyVal = digitalRead(Key);
i...