Problem with Code, Conductive Foam Sensor w/ Speaker

Hey everyone,
Super beginner at this and am looking for some help. This for a school project, and advice would be great.
Basically I’m trying to play different melodies depending on the amount of pressure you apply on conductive foam (soon to be a FSR sensor). I’ve played with the code for hours and can’t seem to reach anywhere but playing an annoying tone and changing the pitch.

#include "pitch.h"

const int threshold = 15;    // minimum reading of the sensors that generates a note

int melody1 [ ] = {
  NOTE_A4};
  
int melody2 [ ] = {
  NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
  
int melody3 [ ] = {
  NOTE_DS8};

void setup() {
  // initialize serial communications (for debugging only):
  Serial.begin(9600);
  

}

void loop() {
  // read the sensor:
  int sensorReading = analogRead(A0);
 for (int thisNote = 0; thisNote < 8; thisNote++) {
   
  // print the sensor reading so you know its range
  Serial.println(sensorReading);
  
 switch (sensorReading) {
   case 1:
   if ((sensorReading > threshold) && (sensorReading < 60)){
   tone(8, melody1[thisNote], 10);
   }
   
   case 2:
   if ((sensorReading > 70) && (sensorReading < 80)){
   tone(8, melody2[thisNote], 10);
   }
   
   case 3:
   if ((sensorReading > 90) && (sensorReading < 150)){
   tone(8, melody3[thisNote], 10);
   }}
}
}

I appreciate any and all feedback, and thanks in advance!

  int sensorReading = analogRead(A0);

The value in sensorReading will be between 0 and 1023. You have defined actions to be performed in the 8 note loop for only 3 of those values (1, 2, and 3). You need 1,021 more case statements.

Or a complete re-write of the code.

What would be a better way of going about this code wise? I couldn't use the "if" statement as their are 3 things i need executed.

Thanks

What would be a better way of going about this code wise? I couldn't use the "if" statement as their are 3 things i need executed.

Why not?

if(someCondition == true)
{
   // Do thing 1
   // Do thing 2
   // Do thing 3
}

The idea for the final outcome for the project will be basically a target with 3 different rings, depending on which ring the shooter hits i want a different sound played. To do this the sensor will be mounted behind the bullseye, the pressure will be the greatest if they hit the bullseye vs the outer ring. I need the arduino to measure the pressure and play a corresponding melody depending upon which ring they hit on the target.

if(someCondition == true)
{
   // Do thing 1
   // Do thing 2
   // Do thing 3
}

Would this still work then, hearing what i want to achieve? I though the if statement was like a fork in a road, you could only go one direction or another. Or would inside the "Do thing " would that be where it measures the pressure and executes the melody?

Perhaps you need to worry less about the playMelody() function that you will write, and more about the validity of the assumption that "the pressure will be the greatest if they hit the bullseye vs the outer ring."

Create a sketch to read and print the value from analogRead, after you have connected the sensor. Shoot at the bullseye and other rings, and see if you get a clear relationship between the point hit and the reading.

If you do, then you really only have one thing to do - play a tune. Which tune to play will depend on the sensor reading. Create one function, playMelody() that takes an argument to define which melody to play (1, 2, or 3).

Have playMelody() call playMelody1(), playMelody2(), or playMelody3(). Then, have each playMelodyN() function play some (different) series of notes.