Project 7 - Keyboard Instrument not working, please help!

Hey Guys,

I am just starting out with Arduino and working through the project book so I am pretty green at the moment. Please excuse any ignorance! :slight_smile:

I am having trouble with a number of projects, but lately I can't get Project 7 - Keyboard Instrument to work, at all.

I am not sure where I am going wrong, I have followed all the steps in the wiring diagram and code. But I'll post pictures of both.

I do have trouble grasping some concepts, but particularly selecting the right resistor - as I struggle to read and identify them correctly.

Any help will be appreciated!

int notes[] = { 262, 294, 330, 349 };
void setup() {
  Serial.begin(9600);
}
void loop() {
  int keyVal = analogRead(A0);
  Serial.println(keyVal);
  if (keyVal == 1023) {
    tone(8, notes[0]);
  } else if (keyVal >= 990 && keyVal <= 1010) {
    tone(8, notes[1]);
  } else if (keyVal >= 505 && keyVal <= 515) {
    tone(8, notes[2]);
  } else if (keyVal >= 5 && keyVal <= 10) {
    tone(8, notes[3]);
  } else {
    noTone(8);
  }
}

Find out how those buttons work. Connecting diagonally is often used…

Does your circuit layout ('schematic') look like this?

EDIT: 30/12/25

No reply yet, but if it’s ‘Yes’ then, like several I’ve seen it’s wrong. Try this correct version;

  • Confirm the A0 voltages when switches are pressed.
    Use a voltmeter to measure the voltages.

  • Write diagnostic code that always output a 3000Hz tone to pin 8.

From the top:
10000/(10000+0) * 1023 ~= 1023

10000/(10000+1000) * 1023 ~= 930

10000/(10000+10000) * 1023 ~= 511

10000/(10000+470) * 1023 ~= 970

If I've read those resistor values correctly, the ADC values obtained are outside your range checks, except for the 10K + 10K button (second from bottom) and the 10K + 0 button (top). Therefore, you should get sound from those two only.

Edit: and if there's any resistance at all in your connection to the breadboard's power rail and the top button, you won't get any sound out of that one.

Edit again: and if the 10K resistors fall at the extreme ends of their tolerance (one high and one low), you may not get anything out of the second from button button either as the ADC value could go as high as 516.