Problem with looping my VoidLoop

Hello , i need some help , i just started to programing with Arduino , and i have problem with my code.
Firstly i programd a code without sound buzzer , then with it. In program where i have buzzer “My loop wont loop”, i klick botton on remote and i get only 1 respond.

Here is first Code that works

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <NECIRrcv.h> 
#define IRPIN 7
NECIRrcv ir(IRPIN) ;
#define BUZZER 8

byte customChar[8] = {
	0b10101,
	0b01010,
	0b10101,
	0b01010,
	0b10101,
	0b01010,
	0b10101,
	0b01010
}; 

byte customChar2[8] = {
	0b01110,
	0b10001,
	0b11001,
	0b11101,
	0b10111,
	0b10011,
	0b10001,
	0b01110
};
void setup() {
  
  lcd.createChar(0, customChar);
  lcd.createChar(1, customChar2);
  
  lcd.begin(16, 2);
  lcd.print("Press key");
  delay(1000);
  lcd.setCursor(0, 1);
  
  pinMode(8, OUTPUT); 
   ir.begin() ;
}
void loop() {
  
unsigned long ircode ;

  while (ir.available()) {
    ircode = ir.read() ;
    Serial.print("got code: 0x") ;
    Serial.println(ircode, HEX);
    
    
    lcd.clear();
    
    lcd.setCursor(0, 0);
   
    if(ircode == 2231601134)
    {lcd.write((uint8_t)0);
      lcd.print(" Access granted ");
    lcd.write((uint8_t)0);
    toggle();
    }
else 
{lcd.write((uint8_t)1);
  lcd.print(" Access deneid ");
  lcd.write((uint8_t)1);
  }
 }
}

This one wont work, only one loop and thats it

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <NECIRrcv.h> 
#define IRPIN 7
NECIRrcv ir(IRPIN) ;
#define BUZZER 8

byte customChar[8] = {
	0b10101,
	0b01010,
	0b10101,
	0b01010,
	0b10101,
	0b01010,
	0b10101,
	0b01010
}; 

byte customChar2[8] = {
	0b01110,
	0b10001,
	0b11001,
	0b11101,
	0b10111,
	0b10011,
	0b10001,
	0b01110
};
void setup() {
  
  lcd.createChar(0, customChar);
  lcd.createChar(1, customChar2);
  
  lcd.begin(16, 2);
  lcd.print("Press key");
  delay(1000);
  lcd.setCursor(0, 1);
  
  pinMode(8, OUTPUT); 
   ir.begin() ;
}


void loop() 
{unsigned long ircode ;

  while (ir.available()) {
    ircode = ir.read() ;
    Serial.print("got code: 0x") ;
    Serial.println(ircode, HEX);
    
    
    lcd.clear();
    
    lcd.setCursor(0, 0);
   
    if(ircode == 2231601134)
    {lcd.write((uint8_t)0);
      lcd.print(" Access granted ");
    lcd.write((uint8_t)0);
     delay(1500);
    buzzer();
     delay(100);
    }
    else 
      {lcd.write((uint8_t)1);
        lcd.print(" Access deneid ");
        lcd.write((uint8_t)1);
         delay(1500);
        alarm();
         delay(100);
  }
 }
}
  void buzzer(){
     tone(8, 1500);
          delay(300);
        noTone(8);
          delay(100);
 }
  void alarm(){
      tone(8, 1500,500);
        tone(8, 1500,500);
      noTone (8);    
        delay(100);
}

Please respond

I don't see how this works in either version

if(ircode == 2231601134)

Earlier you have

ircode = ir.read() ;

so as far as I can see IRcode will never hold anything except a single byte

Can you write a short version of the sketch without using LCD stuff as it just confuses things and I don't have an LCD to test it on.

...R

Cab you write a short version of the sketch without using LCD stuff as it just confuses things and I don't have an LCD to test it on.

And, use Tools + Auto Format before posting any more crappy looking code.

Robin2:
I don’t see how this works in either version

if(ircode == 2231601134)

Earlier you have

ircode = ir.read() ;

so as far as I can see IRcode will never hold anything except a single byte

First im gona say that what you noticed its not the problem, coz this is ircode = ir.read() ; where i get information from my IReciver , then i have if(ircode == 2231601134) this code to make only one correct key from IRemote.
If recived code is 2231601134 my lcd will print access granted , else access denied. Do you under stand?
Here is code without LCD

#include <NECIRrcv.h>
#define IRPIN 7
NECIRrcv ir(IRPIN) ;
#define BUZZER 8


void setup() {


  pinMode(8, OUTPUT);
  ir.begin() ;
}


void loop()
{ unsigned long ircode ;

  while (ir.available()) {
    ircode = ir.read() ;
    Serial.print("got code: 0x") ;
    Serial.println(ircode, HEX);



    if (ircode == 2231601134)
    { buzzer();
      delay(100);
    }
    else
    { alarm();
      delay(100);
    }
  }
}
void buzzer() {
  tone(8, 1500);
  delay(300);
  noTone(8);
  delay(100);
}
void alarm() {
  tone(8, 1500);
  delay(500);
  tone(8, 1500);
  delay(500);
  noTone (8);
  delay(100);
}

Nothing goes on the line after the {.

Extraneous blank lines do not improve the readability of your code.

Random indenting does not improve the readability of your code.

You got some serial output. You didn't share it. It's hard to help greedy people.

You will have to explain what ir.available() and ir.read() do.

It seems as if ir.read() returns a LONG value all in one go. If so, why have you WHILE ir.available() when it would seem that IF ir.available() would make more sense. Perhaps your code is stuck in an interminable WHILE loop.

It was the WHILE that made me think it was reading 1 byte at a time.

Also, I don't understand why the calls to buzzer() and alarm() are within the WHILE (or IF, if you change it).

...R