break statements

I have made a simple keyboard with a 1602LCD and i recently edited it to make it also controllable with IR. Regarding my last post, i have fixed the timers but when i push a button on the remote, it makes the sound but its very choppy and the green led that says a sound is playing, starts flashing, i have break statements but when i push the OFF button to turn of the noise, it wont work as if the program gets stuck in the particular case that it started when i push a button on the remote

code was too big for one post

#include <IRremote.h>
#include <toneAC.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int button1 = A0;
int button2 = A1;
int button3 = A2;
int button4 = A3;
int button5 = 6;
int button6 = 8;
int buzzer = 7;
int led = 7;      //green LED
int led2 = A5;  //red LED
int screen = 40;
int setupDelay = 500;
int loopDelay = 2000;
int RECV_PIN = 13;
int digit = 0;
int buzzerState = LOW;
long previousMillis = 0;
long interval = 1;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define Button0 0xFF6897
#define Button1 0xFF30CF
#define Button2 0xFF18E7
#define Button3 0xFF7A85
#define Button4 0xFF10EF
#define Button5 0xFF38C7
#define Button6 0xFF5AA5
#define Button7 0xFF42BD
#define Button8 0xFF4AB5
#define Button9 0xFF52AD
void setup()
{
  irrecv.enableIRIn();
  lcd.begin(16, 2);
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Made by Mike P.!");
  delay(5000);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  delay(2000);
  lcd.setCursor(0, 1);
  lcd.print("Starting Up...");
  delay(2750);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait.");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait..");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait...");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait.");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait..");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait...");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait.");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait..");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait...");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait.");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait..");
  delay(setupDelay);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait...");
  delay(2000);
  lcd.clear();
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("SETTING UP I/O..");
  delay(3000);
  pinMode(button1,INPUT);
  pinMode(button2,INPUT);
  pinMode(button3,INPUT);
  pinMode(button4,INPUT);
  pinMode(button5,INPUT);
  pinMode(button6,INPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(led,OUTPUT); 
  pinMode(led2,OUTPUT); 
  delay(2500);
  lcd.clear();
  delay(1000);
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Ready!");
  toneAC(440,5);
  delay(500);
  toneAC();;
 lcd.print("SOUND BOARD V2.3");
}
void loop()
{
  unsigned long currentMillis = millis();
  
  if (digitalRead(button1) == HIGH) {
    delay(screen);
  digitalWrite(led2,LOW);
  digitalWrite(led,HIGH);
  toneAC(440,5);
  lcd.clear();
    lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("440 Hz");
  }
  if (digitalRead(button2) == HIGH) {
        delay(screen);
  digitalWrite(led2,LOW);
  digitalWrite(led,HIGH);
  toneAC(400,5);
  lcd.clear();
    lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("400 Hz");
  }
  if (digitalRead(button3) == HIGH) {
        delay(screen);
  digitalWrite(led2,LOW);
  digitalWrite(led,HIGH);
  toneAC(360,5);
  lcd.clear();
    lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("360 Hz");
  }
  if (digitalRead(button4) == HIGH) {
        delay(screen);
  digitalWrite(led2,LOW);
  digitalWrite(led,HIGH);
  toneAC(320,5);
  lcd.clear();
    lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("320 Hz");
  }
  if (digitalRead(button5) == HIGH) {
        delay(screen);
  digitalWrite(led2,LOW);
  digitalWrite(led,HIGH);
  toneAC(280,5);
  lcd.clear();
    lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("280 Hz");
  }
  if (digitalRead(button6) == HIGH) {
        delay(screen);
  digitalWrite(led2,LOW);
  digitalWrite(led,HIGH);
  toneAC(230,5);
  lcd.clear();
    lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("230 Hz");
  }
  if(digitalRead(button1) == LOW && digitalRead(button2) == LOW && digitalRead(button3) == LOW && digitalRead(button4) == LOW && digitalRead(button5) == LOW && digitalRead(button6) == LOW) {
    delay(150);
  lcd.clear();
  digitalWrite(led2,HIGH);
  digitalWrite(led,LOW);
  toneAC();;
    lcd.print("SOUND BOARD V2.3d");
  lcd.setCursor(0, 1);
  lcd.print("NO SOUND PLAYING");
  }
  if (irrecv.decode(&results)) {
    switch (results.value)  {
      case Button0:
        lcd.clear();
        digitalWrite(led2,HIGH);
        digitalWrite(led,LOW);
        toneAC();
        lcd.print("SOUND BOARD V2.3d");
        lcd.setCursor(0, 1);
        lcd.print("NO SOUND PLAYING");
        break;
      case Button1:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(440);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("SOUND BOARD V2.3");
        lcd.setCursor(0, 1);
        lcd.print("440 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      case Button2:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(400);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("SOUND BOARD V2.3");
        lcd.setCursor(0, 1);
        lcd.print("400 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      case Button3:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) { 
     toneAC(360);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("SOUND BOARD V2.3");
        lcd.setCursor(0, 1);
        lcd.print("360 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      case Button4:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(320);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("SOUND BOARD V2.3");
        lcd.setCursor(0, 1);
        lcd.print("320 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      case Button5:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(280);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("SOUND BOARD V2.3");
        lcd.setCursor(0, 1);
        lcd.print("280 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      case Button6:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(230);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("SOUND BOARD V2.3");
        lcd.setCursor(0, 1);
        lcd.print("230 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      case Button7:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(180);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("TRIAL BUTTON 7");
        lcd.setCursor(0, 1);
        lcd.print("180 Hz");
      }
           else
     toneAC();
        break;
      }
      case Button8:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(130);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("TRIAL BUTTON 8");
        lcd.setCursor(0, 1);
        lcd.print("130 Hz");
      }
           else {
     toneAC();
           }
      break; 
      } 
      case Button9:
      if(currentMillis - previousMillis > interval) {
   previousMillis = currentMillis;
      if(buzzerState == LOW) {
     toneAC(80);
        digitalWrite(led2,LOW);
        digitalWrite(led,HIGH);
        lcd.clear();
        lcd.print("TRIAL BUTTON 9");
        lcd.setCursor(0, 1);
        lcd.print("80 Hz");
      }
           else {
     toneAC();
           }
        break;
      }
      default:
         digitalWrite(led2,LOW);
         digitalWrite(led,LOW);
         toneAC();
    }  
        
  }  
}

It probably won’t make a difference but you should get rid of the warnings that are produced.
These two

long previousMillis = 0;
long interval = 1;

should be unsigned long.

Pete

lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Please Wait.");

When you start seeing the same bit of code over and over again, it's time to look at subroutines and PROGMEM.

whats a subroutine and i just need to know why it will only let me select once and then any other button wont do anything, its supposed to be if i press 1 on the remote, i makes a 440 hz sound, i want to be able to then press 2 and make it 400hz, after i press 1, it gets stuck in the Button1 case and then it wont listen to any further input via the remote

A subroutine is a function. Are your punctuation keys broken?

code was too big for one post

Maybe that was a sign

Well if your saying the setup could be a subroutine, couldn't it just be a for loop? But can you help me with the bottom of the loop becuase it seems to ignore the break statement and it gets stuck in a case

You appear to have near-identical code in setup() and loop. It seems to be flashing the text "SOUND BOARD V2.3" although the durations and the actual text may not be exactly identical - were they supposed to be?

The stuff at the top of loop() gets executed right after setup() so you are doing the flashy-thing twice in a row before looking at any input buttons. The simple solution is just take it out of setup(). The more complex solution is to put that into a function and then both setup() and loop) can call the flashyThing() function at any time.

Then to the real problem: you check if all the buttons are LOW and delay for 150ms before going ahead and doing something anyway. Why do you even check this? Were you expecting it to wait here until a button is pushed. A while() loop can do that.

am I reading that wrong or have you got 6 push buttons and a infra-red remote with 9 buttons and you are calling them both the same name? so "button1" is used by both the push button and the remote

also the "please wait" in the set up does nothing more than make the dots move. Its not actually waiting for anything just showing off that you can animate 3 dots using a lot of code to do it. if you want to do that its your project but it can be done using a lot less code.

Mike44449: code was too big for one post

You can attach code to posts.

How to use this forum

What do u mean MorganS? i have only been doing arduino for 2 weeks with my only prior coding knowledge in lua, and C is much different, so please be patient. What do i take out of setup()? the reason it shows the title of the program everywhere is merely an inefficiency. i can fix that later, what is the flashything?

And yes, gpop1, as far as i know, i can put the animation in a for loop, but there is button1-6 and
later i define the buttons and the remote and i see the problem, i can fix that quickly.

merely an inefficiency

that makes your program not work.

my problem is not the animation, it has never caused a problem ever since i first made this program. fixing it does not solve my real problem, the only negative thing it does for now is take up a few extra bytes which i am not concerned about at the moment, my concern is fixing the problem with the remote and i think that renaming some variables might help, i did that, but im waiting for another solution as another road to take.

How are the buttons wired to the pins? Are you using pullup or pulldown resistors.

Pete

like i said, im not very good, i have the 5v going through a 330 ohm which then goes to the pushbuttons and then to their pins.

And by the way, the pushbutton sound keyboard works absolutely fine, my only problem is when i try to use the remote

well if you want to shorten the code at the beginning you can just delete a whole load of lines and add a for loop like this

#include <IRremote.h>
#include <toneAC.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int button1 = A0;
int button2 = A1;
int button3 = A2;
int button4 = A3;
int button5 = 6;
int button6 = 8;
int buzzer = 7;
int led = 7;      //green LED
int led2 = A5;  //red LED
int screen = 40;
int setupDelay = 500;
int loopDelay = 2000;
int RECV_PIN = 13;
int digit = 0;
int buzzerState = LOW;
long previousMillis = 0;
long interval = 1;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define Button0 0xFF6897
#define Button1 0xFF30CF
#define Button2 0xFF18E7
#define Button3 0xFF7A85
#define Button4 0xFF10EF
#define Button5 0xFF38C7
#define Button6 0xFF5AA5
#define Button7 0xFF42BD
#define Button8 0xFF4AB5
#define Button9 0xFF52AD
void setup()
{
  irrecv.enableIRIn();
  lcd.begin(16, 2);
  lcd.print("SOUND BOARD V2.3");
  lcd.setCursor(0, 1);
  lcd.print("Made by Mike P.!");
  delay(5000);
  lcd.setCursor(0, 1);
  lcd.print("Starting Up...  ");
  delay(2750);
  lcd.setCursor(0, 1);
  lcd.print("Please Wait     ");
  delay(setupDelay);
  //repeat the next section 4 times
 for (int i=0; i <= 4; i++){
  lcd.setCursor(12, 1);
  lcd.print(".  ");
  delay(setupDelay);
  lcd.setCursor(12, 1);
  lcd.print("..");
  delay(setupDelay);
  lcd.setCursor(12, 1);
  lcd.print("...");
  delay(setupDelay);
  lcd.setCursor(12, 1);
  lcd.print("   ");
  delay(setupDelay);
}//end of section 
  delay(2000);
  lcd.setCursor(0, 1);
  lcd.print("SETTING UP I/O..  ");
  delay(3000);
  pinMode(button1,INPUT);
  pinMode(button2,INPUT);
  pinMode(button3,INPUT);
  pinMode(button4,INPUT);
  pinMode(button5,INPUT);
  pinMode(button6,INPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(led,OUTPUT); 
  pinMode(led2,OUTPUT); 
  delay(2500);
  lcd.setCursor(0, 1);
  lcd.print("Ready!       ");
  toneAC(440,5);
  delay(500);
  toneAC();
}

thats exactly what i did, and i made a few other optimizations like shortening and while loops, how would i write this in proper syntax:

while(button2 on remote is pressed) { tone(); digitalwrite(led, stuff); lcd.print("stuff"); }

looking at a learning sample I used months ago there was a line after the "if"

if (irrecv.decode(&results)) { irrecv.resume(); // Receive the next value

have you checked the code you got your example from?

no, so i need to add that last line of your code to tell it to look for another input from the remote?