Melody with delay

ik alittle bit of programing and what i got now is kinda long in coding like 487 lines of code but in collage i was to get a program working and then perfect it and i noticed with delay the board wouldn't respond to any commands, googled it and found out it was a blocking delay so i converted to millis. ever since converting to millis the songs dont sound right, they dont play the right melody, and it sounds like it plays a few melodys before looping back to the first melody before it even finishes the entire song, ive been trying to get it working for 3 weeks and i havent been able to so i am coming here, ima post alittle bit of code but not all of it also i got 7 songs and they are all effected

//Red Note Array
int tempor = 85;
int rnotes[] = {
  NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 
  NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 
  NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4,
  NOTE_A4, 2,
};
int notesr = sizeof(rnotes) / sizeof(rnotes[0]) / 2;
int wholenoter = (60000 * 4) / tempor;
int dividerr = 0, noteDurationr = 0;
//End Red Note Array

     for (int thisNote = 0; thisNote < notesr * 2; thisNote = thisNote + 2) {
    dividerr = rnotes[thisNote + 1];
    if (dividerr > 0) {
      noteDurationr = (wholenoter) / dividerr;
    } else if (dividerr < 0) {
      noteDurationr = (wholenoter) / abs(dividerr);
      noteDurationr *= 1.5;
    }
  {
  const long interval = noteDurationr; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, rnotes[thisNote],noteDurationr * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }
  }
  }
  }

Welcome to the forum

Please post your complete sketch

const int BLED=9;      // Blue LED Cathode on Pin 9
const int GLED=10;     // Green LED Cathode on Pin 10
const int RLED=11;     // Red LED Cathode on Pin 11
const int BUTTON=2;    // The Button1 is connected to pin 2
int buttonPin1 = 7; //Start button
int buttonPin2 = 8; //Stop button
boolean lastButton = LOW; //Last Button State
boolean currentButton = LOW; //Current Button State
boolean lastButtonone = LOW; //Last Button State
boolean currentButtonone = LOW; //Current Button State
boolean lastButtontwo = LOW; //Last Button State
boolean currentButtontwo = LOW; //Current Button State
int ledMode = 0; //cycle between LED states
int play = 0; //cycle between LED states
#include "pitches.h" //Header file with pitch definitions
#define REST  0
int SpeakerState = LOW;
const int SPEAKER=5;  //Speaker Pin
unsigned long previousMillis = 0;



//Red Note Array
int tempor = 85;
int rnotes[] = {
  NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 
  NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 
  NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4,
  NOTE_A4, 2,
};
int notesr = sizeof(rnotes) / sizeof(rnotes[0]) / 2;
int wholenoter = (60000 * 4) / tempor;
int dividerr = 0, noteDurationr = 0;
//End Red Note Array

//Green Note Array
int tempog = 132;
int gnotes[] = { 
  NOTE_C4,-8, NOTE_E4,16, NOTE_G4,8, NOTE_C5,8, NOTE_E5,8, NOTE_D5,8, NOTE_C5,8, NOTE_A4,8,
  NOTE_FS4,8, NOTE_G4,8, REST,4, REST,2,
  NOTE_C4,-8, NOTE_E4,16, NOTE_G4,8, NOTE_C5,8, NOTE_E5,8, NOTE_D5,8, NOTE_C5,8, NOTE_A4,8,
  NOTE_G4,-2, NOTE_A4,8, NOTE_DS4,1,
  
  NOTE_A4,8,
  NOTE_E4,8, NOTE_C4,8, REST,4, REST,2,
  NOTE_C4,-8, NOTE_E4,16, NOTE_G4,8, NOTE_C5,8, NOTE_E5,8, NOTE_D5,8, NOTE_C5,8, NOTE_A4,8,
  NOTE_FS4,8, NOTE_G4,8, REST,4, REST,4, REST,8, NOTE_G4,8,
  NOTE_D5,4, NOTE_D5,4, NOTE_B4,8, NOTE_G4,8, REST,8, NOTE_G4,8,
   
  NOTE_C5,4, NOTE_C5,4, NOTE_AS4,16, NOTE_C5,16, NOTE_AS4,16, NOTE_G4,16, NOTE_F4,8, NOTE_DS4,8,
  NOTE_FS4,4, NOTE_FS4,4, NOTE_F4,16, NOTE_G4,16, NOTE_F4,16, NOTE_DS4,16, NOTE_C4,8, NOTE_G4,8,
  NOTE_AS4,8, NOTE_C5,8, REST,4, REST,2,
};
int notesg = sizeof(gnotes) / sizeof(gnotes[0]) / 2;
int wholenoteg = (60000 * 4) / tempog;
int dividerg = 0, noteDurationg = 0;

//Blue Note Array
int tempob = 180;
int bnotes[] = { 
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  NOTE_FS5,-4, NOTE_E5,8, NOTE_FS5,4,
  NOTE_D5,-2,
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  NOTE_FS5,-1,
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  
  NOTE_FS5,-4, NOTE_E5,8, NOTE_FS5,4,
  NOTE_D5,-2,
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  NOTE_FS5,-1,
};
int notesb = sizeof(bnotes) / sizeof(bnotes[0]) / 2;
int wholenoteb = (60000 * 4) / tempob;
int dividerb = 0, noteDurationb = 0;

//Purple Note Array
int tempop = 120;
int pnotes[] = { 
  NOTE_G4,8, NOTE_A4,8, NOTE_B4,4, NOTE_D5,4, NOTE_D5,4, NOTE_B4,4, 
  NOTE_C5,4, NOTE_C5,2, NOTE_G4,8, NOTE_A4,8,
  NOTE_B4,4, NOTE_D5,4, NOTE_D5,4, NOTE_C5,4,

  NOTE_B4,2, REST,8, NOTE_G4,8, NOTE_G4,8, NOTE_A4,8,
  NOTE_B4,4, NOTE_D5,4, REST,8, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8,
  NOTE_G4,4, NOTE_C5,4, REST,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8,

  NOTE_A4,4, NOTE_B4,4, REST,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8,
  NOTE_G4,2, REST,8, NOTE_G4,8, NOTE_G4,8, NOTE_A4,8,
  NOTE_B4,4, NOTE_D5,4, REST,8, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8,

  NOTE_G4,4, NOTE_C5,4, REST,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8,
  NOTE_A4,4, NOTE_B4,4, REST,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8,
  NOTE_G4,4, NOTE_F5,8, NOTE_D5,8, NOTE_E5,8, NOTE_C5,8, NOTE_D5,8, NOTE_B4,8,

  NOTE_C5,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, NOTE_A4,8, NOTE_G4,8, NOTE_E4,8, NOTE_G4,8,
  NOTE_G4,4, NOTE_F5,8, NOTE_D5,8, NOTE_E5,8, NOTE_C5,8, NOTE_D5,8, NOTE_B4,8,
  NOTE_C5,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, NOTE_A4,8, NOTE_G4,8, NOTE_E4,8, NOTE_G4,8,
  NOTE_G4,-2, REST,4
};
int notesp = sizeof(pnotes) / sizeof(pnotes[0]) / 2;
int wholenotep = (60000 * 4) / tempop;
int dividerp = 0, noteDurationp = 0;

//Teal Note Array
int tempot = 108;
int tnotes[] = { 
  NOTE_AS4,8, NOTE_AS4,8, NOTE_AS4,8,//1
  NOTE_F5,2, NOTE_C6,2,
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4,  
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4,  
  NOTE_AS5,8, NOTE_A5,8, NOTE_AS5,8, NOTE_G5,2, NOTE_C5,8, NOTE_C5,8, NOTE_C5,8,
  NOTE_F5,2, NOTE_C6,2,
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4,  
  
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4, //8  
  NOTE_AS5,8, NOTE_A5,8, NOTE_AS5,8, NOTE_G5,2, NOTE_C5,-8, NOTE_C5,16, 
  NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8,
  NOTE_F5,8, NOTE_G5,8, NOTE_A5,8, NOTE_G5,4, NOTE_D5,8, NOTE_E5,4,NOTE_C5,-8, NOTE_C5,16,
  NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8,
  
  NOTE_C6,-8, NOTE_G5,16, NOTE_G5,2, REST,8, NOTE_C5,8,//13
  NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8,
  NOTE_F5,8, NOTE_G5,8, NOTE_A5,8, NOTE_G5,4, NOTE_D5,8, NOTE_E5,4,NOTE_C6,-8, NOTE_C6,16,
  NOTE_F6,4, NOTE_DS6,8, NOTE_CS6,4, NOTE_C6,8, NOTE_AS5,4, NOTE_GS5,8, NOTE_G5,4, NOTE_F5,8,
  NOTE_C6,1
};
int notest = sizeof(tnotes) / sizeof(tnotes[0]) / 2;
int wholenotet = (60000 * 4) / tempot;
int dividert = 0, noteDurationt = 0;

//Orange Note Array
int tempoo = 108;
int onotes[] = { 
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,2, NOTE_C4,8, NOTE_D4,8, 
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,-2,
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D5,2, NOTE_C5,4,
  NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 
  NOTE_D4,-2,
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,2, NOTE_C4,8, NOTE_D4,8, 
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,-2,
  NOTE_E4,2, NOTE_G4,4,

  NOTE_D5,2, NOTE_C5,4,
  NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 
  NOTE_F4,8, NOTE_E4,8, NOTE_C4,2,
  NOTE_F4,2, NOTE_E4,8, NOTE_D4,8, 
  NOTE_E4,8, NOTE_D4,8, NOTE_A3,2,
  NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 
  NOTE_F4,8, NOTE_E4,8, NOTE_C4,4, NOTE_F4,4,
  NOTE_C5,-2, 
};
int noteso = sizeof(onotes) / sizeof(onotes[0]) / 2;
int wholenoteo = (60000 * 4) / tempoo;
int dividero = 0, noteDurationo = 0;
 
//White Note Array
int tempow = 140;
int wnotes[] = { 
  NOTE_C4,4, NOTE_C4,8, 
  NOTE_D4,-4, NOTE_C4,-4, NOTE_F4,-4,
  NOTE_E4,-2, NOTE_C4,4, NOTE_C4,8, 
  NOTE_D4,-4, NOTE_C4,-4, NOTE_G4,-4,
  NOTE_F4,-2, NOTE_C4,4, NOTE_C4,8,

  NOTE_C5,-4, NOTE_A4,-4, NOTE_F4,-4, 
  NOTE_E4,-4, NOTE_D4,-4, NOTE_AS4,4, NOTE_AS4,8,
  NOTE_A4,-4, NOTE_F4,-4, NOTE_G4,-4,
  NOTE_F4,-2,
};
int notesw = sizeof(wnotes) / sizeof(wnotes[0]) / 2;
int wholenotew = (60000 * 4) / tempow;
int dividerw = 0, noteDurationw = 0;

void setup()
{
  pinMode (BLED, OUTPUT);   // Set Blue LED as Output
  pinMode (GLED, OUTPUT);   // Set Green LED as Output
  pinMode (RLED, OUTPUT);   // Set Red LED as Output
  pinMode (BUTTON, INPUT);  // Set button as input (not required)
  pinMode(buttonPin1, INPUT);
}
/*
* Debouncing Function
* Pass it the previous button state,
* and get back the current debounced button state.
*/
boolean debounce1(boolean one)
{
    {
  boolean current1 = digitalRead(BUTTON);       // Read the button state
  if (one != current1)                         // If it's different...
  {    
    current1 = digitalRead(BUTTON);             // Read it again
  }
  return current1;                              // Return the current value
  }
}
boolean debounce2(boolean two)
{
  {
  boolean current2 = digitalRead(buttonPin1);       // Read the button state
  if (two != current2)                         // If it's different...
  {    
    current2 = digitalRead(buttonPin1);             // Read it again
  }
  return current2;                              // Return the current value
}
}
/***************************************************************************/

void setMode(int mode)
{
  //RED
  if (mode == 1)
  {
    color(255, 0, 0);
  }
  
  //GREEN
  else if (mode == 2)
  {
    color(0, 255, 0);
  }
  
//BLUE
  else if (mode == 3)
  {
    color(0, 0, 255);
  }
  
  //PURPLE (RED+BLUE)
  else if (mode == 4)
  {
    color(255, 0, 255);
  }
  
  //TEAL (BLUE+GREEN)
  else if (mode == 5)
  {
    color(0, 255, 255);
  }

  //ORANGE (GREEN+RED)
  else if (mode == 6)
  {
    color(255, 150, 0);
  }
  
  //WHITE (GREEN+RED+BLUE)
  else if (mode == 7)
  {
    color(255, 255, 255);
  }
  
  //OFF (mode = 0)
  else
  {
    color(0, 0, 0);
}
}
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function

{

analogWrite(RLED, red);
analogWrite(GLED, green);
analogWrite(BLED, blue);

}
void setModeone(int mode)
{
  if (mode == 1)
    {
      if (ledMode == 1){
     for (int thisNote = 0; thisNote < notesr * 2; thisNote = thisNote + 2) {
    dividerr = rnotes[thisNote + 1];
    if (dividerr > 0) {
      noteDurationr = (wholenoter) / dividerr;
    } else if (dividerr < 0) {
      noteDurationr = (wholenoter) / abs(dividerr);
      noteDurationr *= 1.5;
    }
  {
  const long interval = noteDurationr; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, rnotes[thisNote],noteDurationr * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }
  }
  }
  }
  }
  else if (ledMode == 2){
     for (int thisNote = 0; thisNote < notesg * 2; thisNote = thisNote + 2) {
    dividerg = gnotes[thisNote + 1];
    if (dividerg > 0) {
      noteDurationg = (wholenoteg) / dividerg;
    } else if (dividerg < 0) {
      noteDurationg = (wholenoteg) / abs(dividerg);
      noteDurationg *= 1.5;
    }
  {
  const long interval = noteDurationg; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, gnotes[thisNote], noteDurationg * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
  }       
  }
  }
  }
  }
    else if (ledMode == 3){
     for (int thisNote = 0; thisNote < notesb * 2; thisNote = thisNote + 2) {
    dividerb = bnotes[thisNote + 1];
    if (dividerb > 0) {
      noteDurationb = (wholenoteb) / dividerb;
    } else if (dividerg < 0) {
      noteDurationb = (wholenoteb) / abs(dividerb);
      noteDurationb *= 1.5;
    }
  {
  const long interval = noteDurationb; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, bnotes[thisNote], noteDurationb * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }       
  }
  }
     }
  }
    else if (ledMode == 4){
     for (int thisNote = 0; thisNote < notesp * 2; thisNote = thisNote + 2) {
    dividerp = pnotes[thisNote + 1];
    if (dividerp > 0) {
      noteDurationp = (wholenotep) / dividerp;
    } else if (dividerg < 0) {
      noteDurationp = (wholenotep) / abs(dividerp);
      noteDurationp *= 1.5;
    }
  {
  const long interval = noteDurationp; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, pnotes[thisNote], noteDurationp * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }       
  }
  }
  }
  }
    else if (ledMode == 5){
     for (int thisNote = 0; thisNote < notest * 2; thisNote = thisNote + 2) {
    dividert = tnotes[thisNote + 1];
    if (dividert > 0) {
      noteDurationt = (wholenotet) / dividert;
    } else if (dividert < 0) {
      noteDurationt = (wholenotet) / abs(dividert);
      noteDurationt *= 1.5;
    }
  {
  const long interval = noteDurationt; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, tnotes[thisNote], noteDurationt * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }       
  }
  }
  }
  }
    else if (ledMode == 6){
     for (int thisNote = 0; thisNote < noteso * 2; thisNote = thisNote + 2) {
    dividero = onotes[thisNote + 1];
    if (dividero > 0) {
      noteDurationo = (wholenoteo) / dividero;
    } else if (dividero < 0) {
      noteDurationo = (wholenoteo) / abs(dividero);
      noteDurationo *= 1.5;
    }
  {
  const long interval = noteDurationo; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, onotes[thisNote], noteDurationo * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }       
  }
  }
  }
  }
    else if (ledMode == 7){
     for (int thisNote = 0; thisNote < notesw * 2; thisNote = thisNote + 2) {
    dividerw = wnotes[thisNote + 1];
    if (dividerw > 0) {
      noteDurationw = (wholenotew) / dividerw;
    } else if (dividerw < 0) {
      noteDurationw = (wholenotew) / abs(dividerw);
      noteDurationw *= 1.5;
    }
  {
  const long interval = noteDurationw; 
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    if (SpeakerState == LOW) {
      tone(SPEAKER, wnotes[thisNote], noteDurationw * 0.9);
    } else {
      noTone(SPEAKER);
    digitalWrite(SPEAKER, SpeakerState);
    }       
  }
  }
  }
  }
    }
//OFF (mode = 0)
  else
  {
noTone(SPEAKER);
  }
}
/******************************************************/
const int analogPin = 0;//the analog input pin attach to
const int ledPin = 8;//the led attach to
int inputValue = 0;//variable to store the value coming from sensor
int outputValue = 0;//variable to store the output value
/******************************************/
void loop()
{
 { currentButton = debounce1(lastButton);           // Read debounced state
  if (lastButton == LOW && currentButton == HIGH) // If it was pressed...
  {
    ledMode++;                                    // Increment the LED value
  }
  lastButton = currentButton;                     // Reset button value
  if (ledMode == 8) ledMode = 0;
  setMode(ledMode); // Change the LED state
 }
 
 { currentButtonone = debounce2(lastButtonone);           // Read debounced state
  if (lastButtonone == LOW && currentButtonone == HIGH) // If it was pressed...
  {
    play++;                                    // Increment the LED value
  }
  lastButtonone = currentButtonone;                     // Reset button value
  if (play == 2) play = 0;
  setModeone(play); // Change the LED state
 }

}

Your code is very repetitive. It might help to write a function that takes an array of note data and its size, then your massive setModeone function can just call it for the desired melody.

yeah but its my first time coding and the ardrino is doing what i want it to do - the melody/song issue like the song pacman is extremely fast and it only plays a few notes on repeat and not the entire song

Where was the delay() call in your previous code? I'm going to guess you replaced each delay() call by the following code:

        {
          const long interval = noteDurationr;
          unsigned long currentMillis = millis();
          if (currentMillis - previousMillis >= interval) {
            previousMillis = currentMillis;
            if (SpeakerState == LOW) {
              tone(SPEAKER, rnotes[thisNote], noteDurationr * 0.9);
            } else {
              noTone(SPEAKER);
              digitalWrite(SPEAKER, SpeakerState);
            }
          }

Since your code is so repetitive I will only analyze one of your for loops. This loop for rnotes will iterate 13 times. Every time through the loop you recalculate a new noteDurationr. Then you test the current millis() value minus the previous millis() value against noteDurationr. This gets tested ONE time for each iteration. An iteration is going to be way less than 1 millisecond and therefore it is unlikely you will enter that if block.

      for (int thisNote = 0; thisNote < notesr * 2; thisNote = thisNote + 2) {
        dividerr = rnotes[thisNote + 1];
        if (dividerr > 0) {
          noteDurationr = (wholenoter) / dividerr;
        } else if (dividerr < 0) {
          noteDurationr = (wholenoter) / abs(dividerr);
          noteDurationr *= 1.5;
        }
        {
          const long interval = noteDurationr;
          unsigned long currentMillis = millis();
          if (currentMillis - previousMillis >= interval) {
            previousMillis = currentMillis;
            if (SpeakerState == LOW) {
              tone(SPEAKER, rnotes[thisNote], noteDurationr * 0.9);
            } else {
              noTone(SPEAKER);
              digitalWrite(SPEAKER, SpeakerState);
            }
          }
        }
      }

When you switch from delay() to millis() it requires you to significantly restructure your code. You must use the loop() function for ALL of your looping. You will have to get rid of the for loops.

The best way to restructure in your case will be to create variables to track the current song, note, and duration.

Let's say you start on song1/note1 and you have calculated the duration. Every time through the loop() function you will use millis() to determine when to turn the note off. When you turn the note off then increment to the next note and calculate the new duration and do it all over again. However, you are also checking the buttons in loop() so whenever you press a button then you turn the tone off, change songs, reset the note and duration values to the first note in the song and do it all over again.

See i dint know that and i googled alot and everyone said use blinkwithoutdelay and thats what i did and thats what i come up with so i need to remove for loops and create loops() or change them to loops() cause i wanna do it right but if i ant able to then oh well

blinkwithoutdelay is a great example, you just misused/misunderstood the application of it. You don't "create" loops() or "change" them to loops(). You just USE the loop() function to perform your looping because it is called over and over again. It is a complete restructuring of your code.

Ehhhh that sounds like a pain in the ass

I disagree

the blink without delay is delaying to understand how non-blocking timing works.
because the code itself has not much comments and does not link back to an everyday example to get the overview.

IMHO this example is easier to understand.
@Toddl1962 as you wrote

I'm very interested what you say very very honest about how good / easy or how bad / hard this explanation is to understand

Be the change you want to see in the world
best regards Stefan

Not really. Here is a quick and dirty implementation of just the sound functionality of your red note array. Disclaimer: I was not able to test it. All you need to do is add the switches and generalize to switch arrays based on the switch settings:

#include "pitches.h" //Header file with pitch definitions

const int SPEAKER=5;  //Speaker Pin

//Red Note Array
const int tempor = 85;
const int wholenoter = (60000 * 4) / tempor;
const int rnotes[] = {
  NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 
  NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 
  NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4,
  NOTE_A4, 2,
};
const int notesr = sizeof(rnotes) / sizeof(rnotes[0]);
int dividerr = 0;
unsigned long noteDurationr;
//End Red Note Array


void setup()
{
  // Start first note
  dividerr = rnotes[1];
  noteDurationr = (wholenoter) / abs(dividerr);
  if (dividerr < 0) noteDurationr *= 1.5;
  tone(SPEAKER, rnotes[0],noteDurationr * 0.9);
}

void loop()
{
  static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationr) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notesr) thisNote = 0; // start over
    
    // Calculate new duration
    dividerr = rnotes[thisNote + 1];
    noteDurationr = wholenoter / abs(dividerr);
    if (dividerr < 0) noteDurationr *= 1.5;
    
    // Start new note
    tone(SPEAKER, rnotes[thisNote],noteDurationr * 0.9);
  }
}

It is the most basic illustration of use of millis() to time events without the clutter of a bunch of other functionality. It is certainly deficient in useful functionality, that is processing other functions without blocking. Therefore I agree and disagree with your disagreement. :grinning:

omg its so close now i can taste it, thank you ToddL1962 for that, i was able to do that to all the songs and now its the right song and right delay, just more problem it doesn't finish the song like pacman (Green) for example the first part goes well but when the pitch starts to go up it resets the song (all of them are like that) also every time the board is turned on or reset the buzzer beeps lol i like it tho shows its got power

the updated code

const int BLED=9;      // Blue LED Cathode on Pin 9
const int GLED=10;     // Green LED Cathode on Pin 10
const int RLED=11;     // Red LED Cathode on Pin 11
const int BUTTON=2;    // The Button1 is connected to pin 2
int buttonPin1 = 7; //Start button
boolean lastButton = LOW; //Last Button State
boolean currentButton = LOW; //Current Button State
boolean lastButtonone = LOW; //Last Button State
boolean currentButtonone = LOW; //Current Button State
int ledMode = 0; //cycle between LED states
int play = 0; //cycle between LED states
#include "pitches.h" //Header file with pitch definitions
#define REST  0
const int SPEAKER=5;  //Speaker Pin



//Red Note Array
const int tempor = 85;
const int wholenoter = (60000 * 4) / tempor;
const int rnotes[] = {
  NOTE_E5, 8, NOTE_D5, 8, NOTE_FS4, 4, NOTE_GS4, 4, 
  NOTE_CS5, 8, NOTE_B4, 8, NOTE_D4, 4, NOTE_E4, 4, 
  NOTE_B4, 8, NOTE_A4, 8, NOTE_CS4, 4, NOTE_E4, 4,
  NOTE_A4, 2,
};
const int notesr = sizeof(rnotes) / sizeof(rnotes[0]);
int dividerr = 0;
unsigned long noteDurationr;
//End Red Note Array

//Green Note Array
const int tempog = 105;
const int wholenoteg = (60000 * 4) / tempog;
const int gnotes[] = { 
  NOTE_B4, 16, NOTE_B5, 16, NOTE_FS5, 16, NOTE_DS5, 16,
  NOTE_B5, 32, NOTE_FS5, -16, NOTE_DS5, 8, NOTE_C5, 16,
  NOTE_C6, 16, NOTE_G6, 16, NOTE_E6, 16, NOTE_C6, 32, NOTE_G6, -16, NOTE_E6, 8,
  NOTE_B4, 16, NOTE_B5, 16, NOTE_FS5, 16, NOTE_DS5, 16, NOTE_B5, 32,
  NOTE_FS5, -16, NOTE_DS5, 8, NOTE_DS5, 32, NOTE_E5, 32, NOTE_F5, 32,
  NOTE_F5, 32, NOTE_FS5, 32, NOTE_G5, 32, NOTE_G5, 32, NOTE_GS5, 32, NOTE_A5, 16, NOTE_B5, 8
};
const int notesg = sizeof(gnotes) / sizeof(gnotes[0]);
int dividerg = 0;
unsigned long noteDurationg;
//End Green Note Array

//Blue Note Array
const int tempob = 180;
const int wholenoteb = (60000 * 4) / tempob;
const int bnotes[] = { 
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  NOTE_FS5,-4, NOTE_E5,8, NOTE_FS5,4,
  NOTE_D5,-2,
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  NOTE_FS5,-1,
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  
  NOTE_FS5,-4, NOTE_E5,8, NOTE_FS5,4,
  NOTE_D5,-2,
  NOTE_D5,-4, NOTE_A5,8, NOTE_FS5,8, NOTE_D5,8,
  NOTE_E5,-4, NOTE_FS5,8, NOTE_G5,4,
  NOTE_FS5,-1,
};
const int notesb = sizeof(bnotes) / sizeof(bnotes[0]);
int dividerb = 0;
unsigned long noteDurationb;
//End Blue Note Array

//Purple Note Array
const int tempop = 120;
const int wholenotep = (60000 * 4) / tempop;
const int pnotes[] = { 
  NOTE_G4,8, NOTE_A4,8, NOTE_B4,4, NOTE_D5,4, NOTE_D5,4, NOTE_B4,4, 
  NOTE_C5,4, NOTE_C5,2, NOTE_G4,8, NOTE_A4,8,
  NOTE_B4,4, NOTE_D5,4, NOTE_D5,4, NOTE_C5,4,
  NOTE_B4,2, REST,8, NOTE_G4,8, NOTE_G4,8, NOTE_A4,8,
  NOTE_B4,4, NOTE_D5,4, REST,8, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8,
  NOTE_G4,4, NOTE_C5,4, REST,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8,
  NOTE_A4,4, NOTE_B4,4, REST,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8,
  NOTE_G4,2, REST,8, NOTE_G4,8, NOTE_G4,8, NOTE_A4,8,
  NOTE_B4,4, NOTE_D5,4, REST,8, NOTE_D5,8, NOTE_C5,8, NOTE_B4,8,
  NOTE_G4,4, NOTE_C5,4, REST,8, NOTE_C5,8, NOTE_B4,8, NOTE_A4,8,
  NOTE_A4,4, NOTE_B4,4, REST,8, NOTE_B4,8, NOTE_A4,8, NOTE_G4,8,
  NOTE_G4,4, NOTE_F5,8, NOTE_D5,8, NOTE_E5,8, NOTE_C5,8, NOTE_D5,8, NOTE_B4,8,
  NOTE_C5,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, NOTE_A4,8, NOTE_G4,8, NOTE_E4,8, NOTE_G4,8,
  NOTE_G4,4, NOTE_F5,8, NOTE_D5,8, NOTE_E5,8, NOTE_C5,8, NOTE_D5,8, NOTE_B4,8,
  NOTE_C5,8, NOTE_A4,8, NOTE_B4,8, NOTE_G4,8, NOTE_A4,8, NOTE_G4,8, NOTE_E4,8, NOTE_G4,8,
  NOTE_G4,-2, REST,4
};
const int notesp = sizeof(pnotes) / sizeof(pnotes[0]);
int dividerp = 0;
unsigned long noteDurationp;
//End Purple Note Array

//Teal Note Array
const int tempot = 108;
const int wholenotet = (60000 * 4) / tempot;
const int tnotes[] = { 
  NOTE_AS4,8, NOTE_AS4,8, NOTE_AS4,8,//1
  NOTE_F5,2, NOTE_C6,2,
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4,  
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4,  
  NOTE_AS5,8, NOTE_A5,8, NOTE_AS5,8, NOTE_G5,2, NOTE_C5,8, NOTE_C5,8, NOTE_C5,8,
  NOTE_F5,2, NOTE_C6,2,
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4,  
  NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F6,2, NOTE_C6,4, //8  
  NOTE_AS5,8, NOTE_A5,8, NOTE_AS5,8, NOTE_G5,2, NOTE_C5,-8, NOTE_C5,16, 
  NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8,
  NOTE_F5,8, NOTE_G5,8, NOTE_A5,8, NOTE_G5,4, NOTE_D5,8, NOTE_E5,4,NOTE_C5,-8, NOTE_C5,16,
  NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8,
  NOTE_C6,-8, NOTE_G5,16, NOTE_G5,2, REST,8, NOTE_C5,8,//13
  NOTE_D5,-4, NOTE_D5,8, NOTE_AS5,8, NOTE_A5,8, NOTE_G5,8, NOTE_F5,8,
  NOTE_F5,8, NOTE_G5,8, NOTE_A5,8, NOTE_G5,4, NOTE_D5,8, NOTE_E5,4,NOTE_C6,-8, NOTE_C6,16,
  NOTE_F6,4, NOTE_DS6,8, NOTE_CS6,4, NOTE_C6,8, NOTE_AS5,4, NOTE_GS5,8, NOTE_G5,4, NOTE_F5,8,
  NOTE_C6,1
};
const int notest = sizeof(tnotes) / sizeof(tnotes[0]);
int dividert = 0;
unsigned long noteDurationt;
//End Teal Note Array

//Orange Note Array
const int tempoo = 108;
const int wholenoteo = (60000 * 4) / tempoo;
const int onotes[] = { 
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,2, NOTE_C4,8, NOTE_D4,8, 
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,-2,
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D5,2, NOTE_C5,4,
  NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 
  NOTE_D4,-2,
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,2, NOTE_C4,8, NOTE_D4,8, 
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D4,-2,
  NOTE_E4,2, NOTE_G4,4,
  NOTE_D5,2, NOTE_C5,4,
  NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 
  NOTE_F4,8, NOTE_E4,8, NOTE_C4,2,
  NOTE_F4,2, NOTE_E4,8, NOTE_D4,8, 
  NOTE_E4,8, NOTE_D4,8, NOTE_A3,2,
  NOTE_G4,2, NOTE_F4,8, NOTE_E4,8, 
  NOTE_F4,8, NOTE_E4,8, NOTE_C4,4, NOTE_F4,4,
  NOTE_C5,-2, 
};
const int noteso = sizeof(onotes) / sizeof(onotes[0]);
int dividero = 0;
unsigned long noteDurationo;
//End Orange Note Array
 
//White Note Array
const int tempow = 140;
const int wholenotew = (60000 * 4) / tempow;
const int wnotes[] = { 
  NOTE_C4,4, NOTE_C4,8, 
  NOTE_D4,-4, NOTE_C4,-4, NOTE_F4,-4,
  NOTE_E4,-2, NOTE_C4,4, NOTE_C4,8,
  NOTE_D4,-4, NOTE_C4,-4, NOTE_G4,-4,
  NOTE_F4,-2, NOTE_C4,4, NOTE_C4,8,
  NOTE_C5,-4, NOTE_A4,-4, NOTE_F4,-4, 
  NOTE_E4,-4, NOTE_D4,-4, NOTE_AS4,4, NOTE_AS4,8,
  NOTE_A4,-4, NOTE_F4,-4, NOTE_G4,-4,
  NOTE_F4,-2,
};
const int notesw = sizeof(wnotes) / sizeof(wnotes[0]);
int dividerw = 0;
unsigned long noteDurationw;
//End White Note Array

void setup()
{
  pinMode (BLED, OUTPUT);   // Set Blue LED as Output
  pinMode (GLED, OUTPUT);   // Set Green LED as Output
  pinMode (RLED, OUTPUT);   // Set Red LED as Output
  pinMode (BUTTON, INPUT);  // Set button as input (not required)
  pinMode(buttonPin1, INPUT);

    // Start First note
  dividerr = rnotes[1];
  noteDurationr = (wholenoter) / abs(dividerr);
  if (dividerr < 0) noteDurationr *= 1.5;
  tone(SPEAKER, rnotes[0],noteDurationr * 0.9);

      // Start Second note
  dividerg = gnotes[1];
  noteDurationg = (wholenoteg) / abs(dividerg);
  if (dividerg < 0) noteDurationg *= 1.5;
  tone(SPEAKER, gnotes[0],noteDurationg * 0.9);

      // Start Third note
  dividerb = bnotes[1];
  noteDurationb = (wholenoteb) / abs(dividerb);
  if (dividerb < 0) noteDurationb *= 1.5;
  tone(SPEAKER, bnotes[0],noteDurationb * 0.9);

      // Start Fourth note
  dividerp = pnotes[1];
  noteDurationp = (wholenotep) / abs(dividerp);
  if (dividerp < 0) noteDurationp *= 1.5;
  tone(SPEAKER, pnotes[0],noteDurationp * 0.9);

      // Start Fifth note
  dividert = tnotes[1];
  noteDurationt = (wholenotet) / abs(dividert);
  if (dividert < 0) noteDurationt *= 1.5;
  tone(SPEAKER, tnotes[0],noteDurationt * 0.9);

      // Start Sixth note
  dividero = onotes[1];
  noteDurationo = (wholenoteo) / abs(dividero);
  if (dividero < 0) noteDurationo *= 1.5;
  tone(SPEAKER, onotes[0],noteDurationo * 0.9);

      // Start Seventh note
  dividerw = wnotes[1];
  noteDurationw = (wholenotew) / abs(dividerw);
  if (dividerw < 0) noteDurationw *= 1.5;
  tone(SPEAKER, wnotes[0],noteDurationw * 0.9);
}
/*
* Debouncing Function
* Pass it the previous button state,
* and get back the current debounced button state.
*/
boolean debounce1(boolean one)
{
    {
  boolean current1 = digitalRead(BUTTON);       // Read the button state
  if (one != current1)                         // If it's different...
  {    
    current1 = digitalRead(BUTTON);             // Read it again
  }
  return current1;                              // Return the current value
  }
}
boolean debounce2(boolean two)
{
  {
  boolean current2 = digitalRead(buttonPin1);       // Read the button state
  if (two != current2)                         // If it's different...
  {    
    current2 = digitalRead(buttonPin1);             // Read it again
  }
  return current2;                              // Return the current value
}
}
/***************************************************************************/

void setMode(int mode)
{
  //RED
  if (mode == 1)
  {
    color(255, 0, 0);
  }
  
  //GREEN
  else if (mode == 2)
  {
    color(0, 255, 0);
  }
  
//BLUE
  else if (mode == 3)
  {
    color(0, 0, 255);
  }
  
  //PURPLE (RED+BLUE)
  else if (mode == 4)
  {
    color(255, 0, 255);
  }
  
  //TEAL (BLUE+GREEN)
  else if (mode == 5)
  {
    color(0, 255, 255);
  }

  //ORANGE (GREEN+RED)
  else if (mode == 6)
  {
    color(255, 150, 0);
  }
  
  //WHITE (GREEN+RED+BLUE)
  else if (mode == 7)
  {
    color(255, 255, 255);
  }
  
  //OFF (mode = 0)
  else
  {
    color(0, 0, 0);
}
}
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function

{

analogWrite(RLED, red);
analogWrite(GLED, green);
analogWrite(BLED, blue);

}
void setModeone(int mode)
{
  if (mode == 1)
  {
      if (ledMode == 1){
    static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationr) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notesr) thisNote = 0; // start over
    
    // Calculate new duration
    dividerr = rnotes[thisNote + 1];
    noteDurationr = wholenoter / abs(dividerr);
    if (dividerr < 0) noteDurationr *= 1.5;
    
    // Start new note
    tone(SPEAKER, rnotes[thisNote],noteDurationr * 0.9);
    }
  }

  
  else if (ledMode == 2){
  static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationg) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notesg) thisNote = 0; // start over
    
    // Calculate new duration
    dividerg = gnotes[thisNote + 1];
    noteDurationg = wholenoteg / abs(dividerg);
    if (dividerg < 0) noteDurationg *= 1.5;
    
    // Start new note
    tone(SPEAKER, gnotes[thisNote],noteDurationg * 0.9);
    }
  }

  
    else if (ledMode == 3){
static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationb) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notesb) thisNote = 0; // start over
    
    // Calculate new duration
    dividerb = bnotes[thisNote + 1];
    noteDurationb = wholenoteb / abs(dividerb);
    if (dividerb < 0) noteDurationb *= 1.5;
    
    // Start new note
    tone(SPEAKER, bnotes[thisNote],noteDurationb * 0.9);
    }
  }

  
    else if (ledMode == 4){
static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationp) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notesp) thisNote = 0; // start over
    
    // Calculate new duration
    dividerp = pnotes[thisNote + 1];
    noteDurationp = wholenotep / abs(dividerp);
    if (dividerp < 0) noteDurationp *= 1.5;
    
    // Start new note
    tone(SPEAKER, pnotes[thisNote],noteDurationp * 0.9);
    }
  }

  
    else if (ledMode == 5){
static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationt) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notest) thisNote = 0; // start over
    
    // Calculate new duration
    dividert = tnotes[thisNote + 1];
    noteDurationt = wholenotet / abs(dividert);
    if (dividert < 0) noteDurationt *= 1.5;
    
    // Start new note
    tone(SPEAKER, tnotes[thisNote],noteDurationt * 0.9);
    }
  }

  
    else if (ledMode == 6){
static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationo) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= noteso) thisNote = 0; // start over
    
    // Calculate new duration
    dividero = onotes[thisNote + 1];
    noteDurationo = wholenoteo / abs(dividero);
    if (dividero < 0) noteDurationo *= 1.5;
    
    // Start new note
    tone(SPEAKER, onotes[thisNote],noteDurationo * 0.9);
    }
  }

  
    else if (ledMode == 7){
static int thisNote = 0;
  static unsigned long previousMillis = millis();
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= noteDurationw) 
  {
    previousMillis = currentMillis;
    
    // Turn current note off
    noTone(SPEAKER); 

    // Increment to new note
    thisNote++; 
    if (thisNote >= notesw) thisNote = 0; // start over
    
    // Calculate new duration
    dividerw = wnotes[thisNote + 1];
    noteDurationw = wholenotew / abs(dividerw);
    if (dividerw < 0) noteDurationw *= 1.5;
    
    // Start new note
    tone(SPEAKER, wnotes[thisNote],noteDurationw * 0.9);
    }
  }

    
//OFF (mode = 0)
  else
  {
noTone(SPEAKER);
  }
}
}
/******************************************************/
const int analogPin = 0;//the analog input pin attach to
const int ledPin = 8;//the led attach to
int inputValue = 0;//variable to store the value coming from sensor
int outputValue = 0;//variable to store the output value
/******************************************/
void loop()
{
 { currentButton = debounce1(lastButton);           // Read debounced state
  if (lastButton == LOW && currentButton == HIGH) // If it was pressed...
  {
    ledMode++;                                    // Increment the LED value
  }
  lastButton = currentButton;                     // Reset button value
  if (ledMode == 8) ledMode = 0;
  setMode(ledMode); // Change the LED state
 }
 
 { currentButtonone = debounce2(lastButtonone);           // Read debounced state
  if (lastButtonone == LOW && currentButtonone == HIGH) // If it was pressed...
  {
    play++;                                    // Increment the LED value
  }
  lastButtonone = currentButtonone;                     // Reset button value
  if (play == 2) play = 0;
  setModeone(play); // Change the LED state
 }

}

@hyperbiast : do me a favor and use Ctrl-T to autoformat your code.

make the Arduino-IDE the active window
click anywere in the editor-window
press ctrl-T

done

sorry, i just did what the forums told me to do when posting code

nvm..... i fixed it ..... thanks again to todd, wouldn't of gotten it working without you

1 Like

So you didn't read

How to get the best out of this forum

Here is a quote from it

Before posting code, please use Tools / Auto Format at the top of the IDE. It makes the code much easier to read and you will probably find it very helpful yourself

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.