How to loop a var++ inside a Do-While statement

Sorry if it’s messy, but I’m in a rush. I’ll polish the thread one I get back from school.
So my teacher asked us to do some projects for the Italy fair. Arduino happens to be Italian.
And since I don’t have enough knowledge or money to build a robot, I’m going to peform some
musics from UNDERTALE, Heartache, Megalovania, Bonestrousle, Dogsong and Hopes and Dreams.
Since I don’t have a mini computer, I’ll use a Switch potentiometer to select the songs.

I’ll ask later about multiple voices on multiple buzzers, but for now, my question is how do I make my code work. I was always using Ifs and elses for any kind of problems or bugs. But with melodies, I just copied the examlpe code and changed the notes and included a customized pitches.h.

But it came with a For statement, and using a integrer to set “thisNote = 0; thisNote< 64; thisNote++;” is not giving any results. I don’t go very well with programing anyway. I tried Do-While, Switch-Break, but nothing works.

So my question is how do I make (in a syntax context)
music01 play when potMode == 1 and music02 when potMode == 2 ?

#include "pitches.h"

//Dogsong - 10bps - 64/31 notes
int melody[] = {
  00, 00, GS6, 00,
  00, F6, 00, 00,
  CS6, 00, DS6, CS6,
  00, GS5, AS5, CS6,  
  00, 00, AS5, 00,
  00, CS6, 00, 00,
  C6, 00, CS6, DS6,
  00, 00, 00, 00,  
  00, 00, GS6, 00,
  00, F6, 00, 00,
  CS6, 00, DS6, CS6,
  00, GS5, AS5, CS6,  
  FS6, F6, DS6, 00,
  DS6, DS6, AS5, 00,
  AS5, 00, C6, 00,
  CS6, 00, GS5, 00,
  00, 00, GS6, 00,
  00, F6, 00, 00,
  CS6, 00, DS6, CS6,
  00, GS5, AS5, CS6,  
  00, 00, AS5, 00,
  00, CS6, 00, 00,
  C6, 00, CS6, DS6,
  00, 00, 00, 00,  
  00, 00, GS6, 00,
  00, F6, 00, 00,
  CS6, 00, DS6, CS6,
  00, GS5, AS5, CS6,  
  FS6, F6, DS6, 00,
  DS6, DS6, AS5, 00,
  AS5, 00, C6, 00,
  CS6, 00, 00, 00,
  /**/
};

// 10 = 100ms per note
int noteDurations[] = {
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,  
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,  
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,  
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,  
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,  
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,  
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  10,10,10,10,
  /**/
};

void setup(){Serial.begin(9600);}
void loop(){
 int pot1 = analogRead(A1);
 int potMode = pot1 / 256;
 Serial.println(potMode);
 do{
 for (thisNote = 0; thisNote < 128; thisNote++)
 int noteDuration = 1000 / noteDurations[thisNote];
 tone(10, melody[thisNote], noteDuration);
 int pauseBetweenNotes = noteDuration * 1.30;
 delay(pauseBetweenNotes);
 noTone(10);} while (potMode == 1);
}

melodyMultiple01e.ino (1.65 KB)

		do{
		for (thisNote = 0; thisNote < 128; thisNote++)
		int noteDuration = 1000 / noteDurations[thisNote];
		tone(10, melody[thisNote], noteDuration);
		int pauseBetweenNotes = noteDuration * 1.30;
		delay(pauseBetweenNotes);
		noTone(10);} while (potMode == 1);

Since potMiode never changes, the bony of this statement will be executed either once, when you don’t want it to be, or forever.

A do/while is rarely the correct construct to be using.

When the for statement is executed, there is only one statement in the body. You should ALWAYS use curly braces, even if there is to be only one statement in the body, so that the body of the for loop is obvious.