Arduino big project problems

hi, i've made a big arduino program with lot of specialities and there are a lot of issues (problem list at the ending)
here is the code

//instruction manual:f24.link/f1rkb
#include "pitches.h"
#include "IRremote.h"
#include <LiquidCrystal.h>
#include <Keypad.h>
#include "LedControl.h"
#include <SPI.h>
#include <MFRC522.h>
const int ledPin4sensor = 37;     //pin 3 has PWM funtion
String serialread;
const int sensorPin = A14; //pin A0 to read analog input
const int SW_pin = 30; // digital pin connected to switch output
const int X_pin = 2; // analog pin connected to X output
const int Y_pin = 3; // analog pin connected to Y output
unsigned char i;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {22, 23, 24, 25}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {26, 27, 28, 29}; //connect to the column pinouts of the keypad
unsigned long delaytime1 = 500;
unsigned long delaytime2 = 50;
// chanson: les lettres= note (en anglais) chuiffres= aigu ou grave (plus haut plus aigu)
int melody[] = {
  NOTE_D6, NOTE_D6, NOTE_A5, NOTE_A5, NOTE_G5, NOTE_G5, NOTE_G5, NOTE_AS5, NOTE_A5, NOTE_A5, NOTE_F5, NOTE_F5, NOTE_D5,
};
int duration = 150;  // = --- = le temps qu'une note vas jouer
int receiver = 48; // Signal Pin of IR receiver to Arduino Digital Pin 11
int lcdplacement4letter = 0;
int lcdplacement4letterupndown = 0;
int tempPin = 0;
int tempCpublic;
int funcstop ;
int ledPin = 13;  // LED on Pin 13 of Arduino
int pirPin = 100; // Input for HC-S501
int value; //save analog value
int yjoy  = (digitalRead(Y_pin));
int xjoy = (digitalRead(X_pin));
int sjoy = (digitalRead(SW_pin));
int pirValue; // Place to store read PIR Value
int arcade = 0;
int joystickchoose = 0;
char choosedletter = '?';
int buzzer = 34;//the pin of the active buzzer
int photocellPin = 4;     // the cell and 10K pulldown are connected to a0
int photocellReading;     // the analog reading from the sensor divider
int LEDpin = 2;          // connect Red LED to pin 11 (PWM pin)
int LEDbrightness;        //
int buttonApin = 40;
int buttonBpin = 32;
int redledch = 100;
int greenledch = 31;
int blueledch = 100;
int reset = 41;
int Butenchrono = 0;
int chrono = 0;
int chrono2 = 0;
int chronon = 0;
int chronon2 = 0;
int stoy = 2;
int result2 = 3;
int result1 = 2;
int blootoot = 5;
int score1 = 0;
int score2 = 0;
int veritrich1 = 100;
int veritrich2 = 100;

#define RST_PIN   5     // Configurable, see typical pin layout above
#define SS_PIN    100   // Configurable, see typical pin layout above
#define NEW_UID {0xDE, 0xAD, 0xBE, 0xEF}

MFRC522::MIFARE_Key key;

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LedControl lc = LedControl(49, 47, 46, 1);
/*-----( Function )-----*/
void translateIR() // takes action based on IR code received

// describing Remote IR codes

{
  Serial.println(results.value);
  switch (results.value)

  {
    case 0xFFA25D: Serial.println("POWER");
      digitalWrite(reset, LOW);
      break;
    case 0xFFE21D: lcd.begin (0, 0);
      lcdplacement4letter = 0;
      lcdplacement4letterupndown = 0;
      (funcstop = 0);
      lcd.begin(16, 2);
      (arcade = 0);
      break;
    case 0xFF629D: Serial.println("VOL+"); break;
    case 0xFF22DD: lcdplacement4letter -= 1;    break;
    case 0xFF02FD: Serial.println("PAUSE"); (arcade = 1);    break;
    case 0xFFC23D: choosedletter = ' ';   break;
    case 0xFFE01F: Serial.println("DOWN");    break;
    case 0xFFA857: Serial.println("VOL-");    break;
    case 0xFF906F: Serial.println("UP");
      cardverify();
      break;
    case 0xFF9867: EQ();
      Serial.println(funcstop);
      if (funcstop == 1 )
      {
        lcd.setCursor( 3 , 1);
        lcd.print("pressfuncstop");
        Serial.println(funcstop);
      }
      break;
    case 0xFFB04F: (funcstop = 1);    break;
    case 0xFF6897: (choosedletter = 'q');   break;
    case 0xFF30CF: (choosedletter = 'r');    break;
    case 0xFF18E7: (choosedletter = 's');    break;
    case 0xFF7A85: (choosedletter = 't');    break;
    case 0xFF10EF: (choosedletter = 'u');  break;
    case 0xFF38C7: (choosedletter = 'v');   break;
    case 0xFF5AA5: (choosedletter = 'w');  break;
    case 0xFF42BD: (choosedletter = 'x');   break;
    case 0xFF4AB5: (choosedletter = 'y');   break;
    case 0xFF52AD: (choosedletter = 'z');    break;
    case 0xFFFFFFFF: Serial.println(" REPEAT"); break;
    case 551494365: stoy = 0; break;
    case 551520375:  (choosedletter = '1');    break;
    case 551504055:  (choosedletter = '2');    break;
    case 551536695:  (choosedletter = '3');    break;
    case 551495895:  (choosedletter = '4');    break;
    case 551528535:  (choosedletter = '5');    break;
    case 551512215:  (choosedletter = '6');    break;
    case 551544855:  (choosedletter = '7');    break;
    case 551491815:  (choosedletter = '8');    break;
    case 551524455:  (choosedletter = '9');    break;
    case 551487735:  (choosedletter = '0');    break;
    case 551522415:  digitalWrite(buzzer, HIGH);    break;
    case 551489775:  lcd.setCursor(0, 0);
      lcd.print("this is not a tv!;)");
      digitalWrite(reset, HIGH); break;
    case 551510175:  joystickchoose++;  break;
    case 551538735:  arcade = 8;  break;
    case 3873901013:  joystickchoose--;  break;






  }// End Case

  delay(100); // Do not get immediate repeat


} //END translateIR

void cardverify() {
  lcd.setCursor(0, 0);
  lcd.print("please pass your");
  lcd.setCursor(1, 1);
  lcd.print("card or badge  ");
  arcade = 12;
}




void tsfbeep() {
  //bug, a refaire (void loop dans passive buzzer ici)

}



void ireeceev() {
  {
    if (irrecv.decode(&results)) // have we received an IR signal?
    {
      translateIR();
      irrecv.resume(); // receive the next value
    }
  }
}
void EQ() {
  Serial.println(choosedletter);
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print(choosedletter);
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):

  if (lcdplacement4letter == 16)
  {
    lcdplacement4letter = 0;
    lcdplacement4letterupndown = 1;
  }

}
void keypadkeyconvert() {
  char customKey = customKeypad.getKey();
  if (customKey); {
    if (customKey == 'A') {
      (choosedletter = 'a');
    }
    else if (customKey == 'B') {
      (choosedletter = 'b');
    }
    else if (customKey == 'C') {
      (choosedletter = 'c');
    } else if (customKey == 'D') {
      (choosedletter = 'd');
    } else if (customKey == '1') {
      (choosedletter = 'e');
    } else if (customKey == '2') {
      (choosedletter = 'f');
    } else if (customKey == '3') {
      (choosedletter = 'g');
    } else if (customKey == '4') {
      (choosedletter = 'h');
    } else if (customKey == '5') {
      (choosedletter = 'i');
    } else if (customKey == '6') {
      (choosedletter = 'j');
    } else if (customKey == '7') {
      (choosedletter = 'k');
    } else if (customKey == '8') {
      (choosedletter = 'l');
    } else if (customKey == '9') {
      (choosedletter = 'm');
    } else if (customKey == '*') {
      (choosedletter = 'n');
    } else if (customKey == '0') {
      (choosedletter = 'o');
    } else if (customKey == '#') {
      (choosedletter = 'p');

    }

  }
}

void writeArduinoOnMatrix() {
  //Serial.println (tempCpublic);
  /* here is the data for the characters */
  byte a[5] = {B01111110, B10001000, B10001000, B10001000, B01111110};
  byte r[5] = {B00010000, B00100000, B00100000, B00010000, B00111110};
  byte d[5] = {B11111110, B00010010, B00100010, B00100010, B00011100};
  byte u[5] = {B00111110, B00000100, B00000010, B00000010, B00111100};
  byte i[5] = {B00000000, B00000010, B10111110, B00100010, B00000000};
  byte n[5] = {B00011110, B00100000, B00100000, B00010000, B00111110};
  byte o[5] = {B00011100, B00100010, B00100010, B00100010, B00000000};
  byte un[8] = {B00000000, B00000000, B00000001, B00000001, B01111111, B00100001, B00010001, B00000000,};
  byte deux[8] = {B00000000, B00100001, B01010001, B10001001, B10000101, B01000011, B00100001, B00000000,};
  byte vingt[8] = {B00000000, B00011111, B00010001, B00011111, B00000000, B00011101, B00010101, B00010111,};
  byte vingtetun[8] = {B00000000, B00000000, B00011111, B00000000, B00000000, B00011101, B00010101, B00010111,};
  byte vingtdeux[8] = {B00000000, B00011101, B00010101, B00010111, B00000000, B00011101, B00010101, B00010111,};
  byte vingttrois[8] = {B00000000, B00011111, B00010101, B00010101, B00000000, B00011101, B00010101, B00010111,};
  byte vingtquatre[8] = {B00000000, B00011111, B00000100, B00011100, B00000000, B00011101, B00010101, B00010111,};
  byte vingtcinq[8] = {B00000000, B00010111, B00010101, B00011101, B00000000, B00011101, B00010101, B00010111,};
  byte vingtsix[8] = {B00000000, B00010111, B00010101, B00011111, B00000000, B00011101, B00010101, B00010111,};
  byte vingtsept[8] = {B00000000, B00011111, B00010000, B00010000 , B00000000, B00011101, B00010101, B00010111,};
  byte minic[2] = {B10100000, B11100000, };
  /* now display them one by one with a small delay */

  if  (tempCpublic == 1 ) {
    lc.setRow(0, 0, un[0]);
    lc.setRow(0, 1, un[1]);
    lc.setRow(0, 2, un[2]);
    lc.setRow(0, 3, un[3]);
    lc.setRow(0, 4, un[4]);
    lc.setRow(0, 5, un[5]);
    lc.setRow(0, 6, un[6]);
    lc.setRow(0, 7, un[7]);
    lc.setRow(0, 8, un[8]);
    delay(delaytime1);
  }
  if  ( 2 == tempCpublic ) {
    lc.setRow(0, 0, deux[0]);
    lc.setRow(0, 1, deux[1]);
    lc.setRow(0, 2, deux[2]);
    lc.setRow(0, 3, deux[3]);
    lc.setRow(0, 4, deux[4]);
    lc.setRow(0, 5, deux[5]);
    lc.setRow(0, 6, deux[6]);
    lc.setRow(0, 7, deux[7]);
    lc.setRow(0, 8, deux[8]);
    delay(delaytime1);
  }

  if  ( 20 == tempCpublic ) {
    lc.setRow(0, 0, vingt[0]);
    lc.setRow(0, 1, vingt[1]);
    lc.setRow(0, 2, vingt[2]);
    lc.setRow(0, 3, vingt[3]);
    lc.setRow(0, 4, vingt[4]);
    lc.setRow(0, 5, vingt[5]);
    lc.setRow(0, 6, vingt[6]);
    lc.setRow(0, 7, vingt[7]);
    lc.setRow(0, 8, vingt[8]);
    delay(delaytime1);
  }
  if  ( 21 == tempCpublic ) {
    lc.setRow(0, 0, vingtetun[0]);
    lc.setRow(0, 1, vingtetun[1]);
    lc.setRow(0, 2, vingtetun[2]);
    lc.setRow(0, 3, vingtetun[3]);
    lc.setRow(0, 4, vingtetun[4]);
    lc.setRow(0, 5, vingtetun[5]);
    lc.setRow(0, 6, vingtetun[6]);
    lc.setRow(0, 7, vingtetun[7]);
    lc.setRow(0, 8, vingtetun[8]);
    delay(delaytime1);
  }
  if  ( 22 == tempCpublic ) {
    lc.setRow(0, 0, vingtdeux[0]);
    lc.setRow(0, 1, vingtdeux[1]);
    lc.setRow(0, 2, vingtdeux[2]);
    lc.setRow(0, 3, vingtdeux[3]);
    lc.setRow(0, 4, vingtdeux[4]);
    lc.setRow(0, 5, vingtdeux[5]);
    lc.setRow(0, 6, vingtdeux[6]);
    lc.setRow(0, 7, vingtdeux[7]);
    lc.setRow(0, 8, vingtdeux[8]);
    delay(delaytime1);
  }
  if  ( 23 == tempCpublic ) {
    lc.setRow(0, 0, vingttrois[0]);
    lc.setRow(0, 1, vingttrois[1]);
    lc.setRow(0, 2, vingttrois[2]);
    lc.setRow(0, 3, vingttrois[3]);
    lc.setRow(0, 4, vingttrois[4]);
    lc.setRow(0, 5, vingttrois[5]);
    lc.setRow(0, 6, vingttrois[6]);
    lc.setRow(0, 7, vingttrois[7]);
    lc.setRow(0, 8, vingttrois[8]);
    delay(delaytime1);
  }
  if  ( 24 == tempCpublic ) {
    lc.setRow(0, 0, vingtquatre[0]);
    lc.setRow(0, 1, vingtquatre[1]);
    lc.setRow(0, 2, vingtquatre[2]);
    lc.setRow(0, 3, vingtquatre[3]);
    lc.setRow(0, 4, vingtquatre[4]);
    lc.setRow(0, 5, vingtquatre[5]);
    lc.setRow(0, 6, vingtquatre[6]);
    lc.setRow(0, 7, vingtquatre[7]);
    lc.setRow(0, 8, vingtquatre[8]);
    delay(delaytime1);
  }
  if  ( 25 == tempCpublic ) {
    lc.setRow(0, 0, vingtcinq[0]);
    lc.setRow(0, 1, vingtcinq[1]);
    lc.setRow(0, 2, vingtcinq[2]);
    lc.setRow(0, 3, vingtcinq[3]);
    lc.setRow(0, 4, vingtcinq[4]);
    lc.setRow(0, 5, vingtcinq[5]);
    lc.setRow(0, 6, vingtcinq[6]);
    lc.setRow(0, 7, vingtcinq[7]);
    lc.setRow(0, 8, vingtcinq[8]);
    delay(delaytime1);
  }
  if  ( 26 == tempCpublic ) {
    lc.setRow(0, 0, vingtsix[0]);
    lc.setRow(0, 1, vingtsix[1]);
    lc.setRow(0, 2, vingtsix[2]);
    lc.setRow(0, 3, vingtsix[3]);
    lc.setRow(0, 4, vingtsix[4]);
    lc.setRow(0, 5, vingtsix[5]);
    lc.setRow(0, 6, vingtsix[6]);
    lc.setRow(0, 7, vingtsix[7]);
    lc.setRow(0, 8, vingtsix[8]);
    delay(delaytime1);
  }
  if  ( 27 == tempCpublic ) {
    lc.setRow(0, 0, vingtsept[0]);
    lc.setRow(0, 1, vingtsept[1]);
    lc.setRow(0, 2, vingtsept[2]);
    lc.setRow(0, 3, vingtsept[3]);
    lc.setRow(0, 4, vingtsept[4]);
    lc.setRow(0, 5, vingtsept[5]);
    lc.setRow(0, 6, vingtsept[6]);
    lc.setRow(0, 7, vingtsept[7]);
    lc.setRow(0, 8, vingtsept[8]);
    delay(delaytime1);
  }
}
/*
  This function lights up a some Leds in a row.
  The pattern will be repeated on every row.
  The pattern will blink along with the row-number.
  row number 4 (index==3) will blink 4 times etc.
*/
void rows() {
  for (int row = 0; row < 8; row++) {
    delay(delaytime2);
    lc.setRow(0, row, B10100000);
    delay(delaytime2);
    lc.setRow(0, row, (byte)0);
    for (int i = 0; i < row; i++) {
      delay(delaytime2);
      lc.setRow(0, row, B10100000);
      delay(delaytime2);
      lc.setRow(0, row, (byte)0);
    }
  }
}

/*
  This function lights up a some Leds in a column.
  The pattern will be repeated on every column.
  The pattern will blink along with the column-number.
  column number 4 (index==3) will blink 4 times etc.
*/
void columns() {
  for (int col = 0; col < 8; col++) {
    delay(delaytime2);
    lc.setColumn(0, col, B00100000);
    delay(delaytime2);
    lc.setColumn(0, col, (byte)0);
    for (int i = 0; i < col; i++) {
      delay(delaytime2);
      lc.setColumn(0, col, B00100000);
      delay(delaytime2);
      lc.setColumn(0, col, (byte)0);
    }
  }
}

/*
  This function will light up every Led on the matrix.
  The led will blink along with the row-number.
  row number 4 (index==3) will blink 4 times etc.
*/
void single() {
  for (int row = 0; row < 8; row++) {
    for (int col = 0; col < 8; col++) {
      delay(delaytime2);
      lc.setLed(0, row, col, true);
      delay(delaytime2);
      for (int i = 0; i < col; i++) {
        lc.setLed(0, row, col, false);
        delay(delaytime2);
        lc.setLed(0, row, col, true);
        delay(delaytime2);
      }
    }
  }
}
void MAX7() {
  tmpon();
  writeArduinoOnMatrix();
  rows();
  columns();
  single();
}
void tmpon() {


  lcdplacement4letter = 0;
  lcdplacement4letterupndown = 0;
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('t');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('e');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('m');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('p');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print(' ');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('i');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('n');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print(' ');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('c');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('e');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('l');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('c');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('i');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('u');
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcdplacement4letter += 1;
  lcd.print('s');
  lcdplacement4letter = 0;
  lcdplacement4letterupndown += 1;
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcd.print('o');
  lcdplacement4letter += 1;
  lcd.setCursor( lcdplacement4letter , lcdplacement4letterupndown);
  lcd.print('n');

}
void rfid() {
  // Look for new cards, and select one if present
  if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
    delay(50);
    return;
  }

  // Now a card is selected. The UID and SAK is in mfrc522.uid.

  // Dump UID
  Serial.print(F("Card UID:"));
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    //    if (mfrc522.uid.uidByte[i], HEX) == 1;
    //  lcd.print("accsess accepted");
  }
  Serial.println();

  // Dump PICC type
  //  MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
  //  Serial.print(F("PICC type: "));
  //  Serial.print(mfrc522.PICC_GetTypeName(piccType));
  //  Serial.print(F(" (SAK "));
  //  Serial.print(mfrc522.uid.sak);
  //  Serial.print(")\r\n");
  //  if (  piccType != MFRC522::PICC_TYPE_MIFARE_MINI
  //    &&  piccType != MFRC522::PICC_TYPE_MIFARE_1K
  //    &&  piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
  //    Serial.println(F("This sample only works with MIFARE Classic cards."));
  //    return;
  //  }

  // Set new UID
  byte newUid[] = NEW_UID;
  if ( mfrc522.MIFARE_SetUid(newUid, (byte)4, true) ) {
    Serial.println(F("Wrote new UID to card."));
  }

  // Halt PICC and re-select it so DumpToSerial doesn't get confused
  mfrc522.PICC_HaltA();
  if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) {
    return;
  }

  // Dump the new memory contents
  Serial.println(F("New UID and contents:"));
  mfrc522.PICC_DumpToSerial(&(mfrc522.uid));

  delay(2000);
}
void bootmatrix()
{ /*
    The MAX72XX is in power-saving mode on startup,
    we have to do a wakeup call
  */
  lc.shutdown(0, false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0, 8);
  /* and clear the display */
  lc.clearDisplay(0);
}

void setup() {
  {

    pinMode(buttonApin, INPUT_PULLUP);
    pinMode(buttonBpin, INPUT_PULLUP);
    Serial.begin(9600);
    Serial.println("IR Receiver Button Decode");
    irrecv.enableIRIn(); // Start the receiver
    Serial.begin(9600);  // Initialize serial communications with the PC
    while (!Serial);     // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
    SPI.begin();         // Init SPI bus
    mfrc522.PCD_Init();  // Init MFRC522 card
    Serial.println(F("Warning: this example overwrites the UID of your UID changeable card, use with care!"));
    pinMode(49, INPUT);
    digitalWrite(49, HIGH);
    // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
    for (byte i = 0; i < 6; i++) {
      key.keyByte[i] = 0xFF;
    }
  }/*--(end setup )---*/

  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  bootmatrix();
  pinMode(ledPin, OUTPUT);
  pinMode(pirPin, INPUT);

  digitalWrite(ledPin, LOW);
  pinMode(ledPin4sensor, OUTPUT);  //Set pin 3 as 'output'
  Serial.begin(9600);       //Begin serial communication
  pinMode(SW_pin, INPUT);
  digitalWrite(reset, HIGH);  pinMode(reset, OUTPUT);
  digitalWrite(reset, HIGH);
  digitalWrite(SW_pin, HIGH);  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  //digitalWrite(reset, HIGH);
  pinMode(buzzer, OUTPUT); //initialize the buzzer pin as an output
  lcd.setCursor(1, 0);
  lcd.print("Read manual at");
  lcd.setCursor(1, 1);
  lcd.print ("f24.link/F1rKB");
  digitalWrite(SW_pin, HIGH);  pinMode(SW_pin, INPUT);
  digitalWrite(SW_pin, HIGH);
  digitalWrite(greenledch, HIGH);
  pinMode(greenledch, INPUT);
  digitalWrite(greenledch, HIGH);
  digitalWrite(redledch, HIGH);
  pinMode(redledch, INPUT);
  digitalWrite(redledch, HIGH);
  digitalWrite(blueledch, HIGH);
  pinMode(blueledch, INPUT);
  digitalWrite(blueledch, HIGH);

  /*
    This method will display the characters for the
    word "Arduino" one after the other on the matrix.
    (you need at least 5x7 leds to see the whole chars)
  */
}


void loop() { //a un probleme

  while (Serial.available()) { 
    serialread = Serial.readString();
    if (serialread.startsWith("command")) {
      lcd.print("write command");
    }
    else {
      // read the incoming data as string
      lcd.print(serialread);
      Serial.println(serialread);
    }
  }

  keypadkeyconvert();
  tsfbeep();
  ireeceev();
  rfid();
  (sjoy = (digitalRead(SW_pin)));
  (xjoy = (analogRead(X_pin)));
  (yjoy = (analogRead(Y_pin)));

  { value = analogRead(sensorPin);       //Read and save analog value from potentiometer
    //Serial.println(value);               //Print value
    value = map(value, 0, 1023, 0, 255); //Map value 0-1023 to 0-255 (PWM)
    analogWrite(ledPin4sensor, value);          //Send PWM value to led
    delay(1);
  }
  char customKey = customKeypad.getKey();

  if (customKey) {
    Serial.println(customKey);
  }
  int tempReading = analogRead(tempPin);
  // This is OK
  double tempK = log(10000.0 * ((1024.0 / tempReading - 1)));
  tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK )) * tempK );       //  Temp Kelvin
  float tempC = tempK - 273.15;            // Convert Kelvin to Celcius
  /*  replaced
    float tempVolts = tempReading * 5.0 / 1024.0;
    float tempC = (tempVolts - 0.5) * 10.0;
    float tempF = tempC * 9.0 / 5.0 + 32.0;
  */
  // Display Temperature in C
  // Display Temperature in F
  //lcd.print("Temp         F  ");
  // Display Temperature in
  (tempCpublic = (tempC));
  pirValue = digitalRead(pirPin);
  digitalWrite(ledPin, pirValue);
  if (arcade <= 1) {
    if (700 <= yjoy) {
      lcd.begin(16, 2);
      Serial.println("hi");


      for (i = 0; i < 80; i++)
      {
        digitalWrite(buzzer, HIGH);
        delay(1);//wait for 1ms
        digitalWrite(buzzer, LOW);
        delay(1);//wait for 1ms
      }
      arcade += 1;
      //output another frequency
      delay(1000);//wait for 1ms
    }
  }



  if (arcade == 1) {
    {
      lcd.setCursor(1, 0);
      lcd.print("Read manual at");
      lcd.setCursor(1, 1);
      lcd.print ("f24.link/F1rKB");
    }

  }

  if (arcade == 2) {
    {
      if (700 <= yjoy) {
        lcd.setCursor(1, 0);
        lcd.print("choose a game");
        lcd.setCursor(1, 1);
      }
      if (joystickchoose == 0) {
        lcd.print ("    press!");
        //joystickchoose = 1;
        if (sjoy == 0) {
          for (i = 0; i < 80; i++)
          {
            digitalWrite(buzzer, HIGH);
            delay(1);//wait for 1ms
            digitalWrite(buzzer, LOW);
            delay(1);//wait for 1ms
          }
          //output another frequency
          for (i = 0; i < 100; i++)
          {
            digitalWrite(buzzer, HIGH);
            delay(2);//wait for 2ms
            digitalWrite(buzzer, LOW);
            delay(2);//wait for 2ms
            sjoy = 1;
          }
          arcade = 4;
        }
      }
      if (joystickchoose == 1) {
        lcd.setCursor(1, 1);
        lcd.print ("the counter       ");
        //joystickchoose = -1;
        if (sjoy == 0) {
          for (i = 0; i < 80; i++)
          {
            digitalWrite(buzzer, HIGH);
            delay(1);//wait for 1ms
            digitalWrite(buzzer, LOW);
            delay(1);//wait for 1ms
          }
          //output another frequency
          for (i = 0; i < 100; i++)
          {
            digitalWrite(buzzer, HIGH);
            delay(2);//wait for 2ms
            digitalWrite(buzzer, LOW);
            delay(2);//wait for 2ms
            sjoy = 1;

          }
          Butenchrono = (random(3, 22));
          lcd.setCursor(0, 0);
          lcd.print("count ");
          lcd.print(Butenchrono);
          lcd.print(" seconds");
          lcd.setCursor(1, 3);
          lcd.print("   and press!     ") ;
          arcade = 7;
          chronon = 1;
          chronon2 = 1;
        }
      }
    }
    if (joystickchoose == -1) {

      joystickchoose = 1;
    }
    if (joystickchoose == 3) {

      joystickchoose = 0;

    }
    if (joystickchoose == 2) {
      lcd.print ("    click!");
      //joystickchoose = 1;
      if (sjoy == 0) {
        for (i = 0; i < 80; i++)
        {
          digitalWrite(buzzer, HIGH);
          delay(1);//wait for 1ms
          digitalWrite(buzzer, LOW);
          delay(1);//wait for 1ms
        }
        //output another frequency
        for (i = 0; i < 100; i++)
        {
          digitalWrite(buzzer, HIGH);
          delay(2);//wait for 2ms
          digitalWrite(buzzer, LOW);
          delay(2);//wait for 2ms
          sjoy = 1;
        }
        arcade = 9;
      }
    }



  }
  lcd.setCursor(1, 1);

  {

    if (700 <= xjoy) {
      joystickchoose += 1;
    }
    if (xjoy <= 200) {
      joystickchoose -= 1;
    }
  }

  if (arcade == 4) {
    Serial.println(sjoy);
    lcd.setCursor(1, 0);
    lcd.print("n. of players");
    lcd.setCursor(1, 1);
    if (joystickchoose == 0) {

      lcd.print ("     2       ");
      //joystickchoose = -1;
      if (sjoy == 0) {
        arcade = 5;

      }
    }
    if (joystickchoose == 1) {

      lcd.print ("     3       ");
      //joystickchoose = -1;
      if (sjoy == 0) {
        lcd.print("not disponible");
      }
    }
    if (joystickchoose == -1) {

      joystickchoose = 1;
    }
    if (joystickchoose == 2) {

      joystickchoose = 0;
    }



  }
  if (arcade == 5) {
    lcd.setCursor(0, 0);
    lcd.print("                ");
    lcd.setCursor(1, 1);
    lcd.print("get set...");
    Serial.println(random(100, 22000));
    delay(random(100, 22000));
    Serial.println("press");
    lcd.setCursor(1, 1);
    arcade = 6;
    lcd.print("press!     ");

  }
  if (arcade == 6) {
    if (digitalRead(buttonApin) == LOW) {
      lcd.setCursor(1, 1);
      lcd.print("           ");
      lcd.setCursor(1, 0);
      lcd.print("player 1 won!");
      arcade = 0;
    }
    if (digitalRead(buttonBpin) == LOW) {
      lcd.setCursor(1, 1);
      lcd.print("           ");
      lcd.setCursor(1, 0);
      lcd.print("player 2 won!");
      arcade = 0;
    }
  }
  if (arcade == 7) {


    if (digitalRead(buttonBpin) == LOW) {
      chronon2 = 0;
      if (chronon == 0) {
        int result01 =  (chrono - Butenchrono);
        int result012 =  (Butenchrono - chronon );
        int result02 =  (chrono2 - Butenchrono);
        int result022 =  (Butenchrono - chronon2 );
        if (result01 <= result012) {
          int result2 = result01;
        }
        else int result1 = result012;
        if (result02 <= result022) {
          int result1 = result02;
        }
        else int result2 = result022;
        if (result1 <= result2) {
          lcd.setCursor(0, 0);
          lcd.print("   player 1 won!   ");
        }
        if (result2 <= result1) {
          lcd.setCursor(0, 0);
          lcd.print("   player 2 won!   ");
        }
        if (result2 == result1) {
          lcd.setCursor(0, 0);
          lcd.print("    egality!    ");

        }
        lcd.setCursor(0, 1);
        lcd.print(chrono);
        lcd.print("              ");
        lcd.setCursor(14, 1 );
        lcd.print(chrono2);
        arcade = 0;
      }
    }



    if (digitalRead(buttonApin) == LOW) {
      chronon = 0;
      if (chronon2 == 0) {
        int result01 =  (chrono - Butenchrono);
        int result012 =  (Butenchrono - chronon );
        int result02 =  (chrono2 - Butenchrono);
        int result022 =  (Butenchrono - chronon2 );
        if (result01 <= result012) {
          int result2 = result01;
        }
        else int result1 = result012;
        if (result02 <= result022) {
          int result1 = result02;
        }
        else int result2 = result022;
        if (result1 <= result2) {
          lcd.setCursor(0, 0);
          lcd.print("   player 1 won!   ");
        }
        if (result2 <= result1) {
          lcd.setCursor(0, 0);
          lcd.print("   player 2 won!   ");
        }
        if (result2 == result1) {
          lcd.setCursor(0, 0);
          lcd.print("    egality!    ");

        }
        lcd.setCursor(0, 1);
        lcd.print(chrono);
        lcd.print("              ");
        lcd.setCursor(14, 1);
        lcd.print(chrono2);
        arcade = 0;
      }
    }

  }

  if (chronon == 1) {
    delay(910);
    chrono++;
  }
  if (chronon2 == 1) {
    delay(910);
    chrono2++;
  }
  //Serial.println(tempCpublic);
  if (arcade == 8) {
    if (joystickchoose == 0) {
      lcd.setCursor(0, 0);
      lcd.print ("show temperature");
      //joystickchoose = -1;
      if (sjoy == 0) {
        (funcstop = 1);
        if (stoy == 0)  {
          (funcstop = 1);
          stoy = 1;
        }
      }
    }
    /*if (joystickchoose == 2) {
      lcd.setCursor(0,0)
      lcd.print ("show temperature");
      //joystickchoose = -1;
      if (sjoy == 0) {
        arcade = 5;
      if (stoy == 0)
       stoy = 1
      }
      }*/
    if (joystickchoose == 1) {
      lcd.setCursor(0, 0);
      lcd.print ("play a game     ");
      //joystickchoose = -1;
      if (sjoy == 0) {
        arcade = 2;
      }
      if (stoy == 0) {
        arcade = 2;
        stoy = 1;
      }
    }
    if (joystickchoose == -1) {

      joystickchoose = 1;
    }
    if (joystickchoose == 2) {

      joystickchoose = 0;
    }

  }
  /* Serial.println("1:" );
    Serial.println(chrono);
    Serial.println("2:" );
    Serial.println(chrono2);*/
  {
    photocellReading = analogRead(photocellPin);


    // LED gets brighter the darker it is at the sensor
    // that means we have to -invert- the reading from 0-1023 back to 1023-0
    photocellReading = 1023 - photocellReading;
    //now we have to map 0-1023 to 0-255 since thats the range analogWrite uses

    if (photocellReading >= 930) {


      LEDbrightness = map(photocellReading, 0, 1023, 0, 255);
      analogWrite(LEDpin, LEDbrightness);
    }
    else  analogWrite(LEDpin, 0);
    delay(1);
  }
  if (funcstop == 1) {
    MAX7();
  }
  else bootmatrix();
  if (digitalRead(buttonApin) == LOW); {
    digitalWrite(redledch , HIGH);

  }

  if (digitalRead(buttonApin) == HIGH); {
    digitalWrite(redledch , LOW);
  }
  if (digitalRead(buttonApin) == LOW); {
    digitalWrite(blueledch , LOW);

  }
  if (digitalRead(buttonApin) == LOW); {
    digitalWrite(greenledch , HIGH);
  }
  int digitalVal = digitalRead(49);
  if (HIGH == digitalVal)
  {
    delay(0);
  }

  if (analogRead(blootoot) <= 50 ) {
    lcd.setCursor(0, 0);
    lcd.print("not working now!");
  }

  if (arcade == 9) {
    lcd.setCursor(0, 0);
    lcd.print("players,        ");
    delay(1000);
    lcd.setCursor(8, 1);
    lcd.print("      6,              ");
    delay(1000);
    lcd.setCursor(8, 1);
    lcd.print("5,");
    delay(1000);
    lcd.setCursor(8, 1);
    lcd.print("4,");
    delay(1000);
    lcd.setCursor(8, 1);
    lcd.print("3,");
    delay(1000);
    lcd.setCursor(8, 1);
    lcd.print("2,");
    delay(1000);
    lcd.setCursor(8, 1);
    lcd.print("1,");
    delay(1000);
    lcd.setCursor(3, 0);
    lcd.print("DON'T STOP");
    lcd.setCursor(5, 1);
    lcd.print("CLICKING!!");
    chrono = 0;
    arcade = 10;


  }
  if (arcade == 10) {
    chrono += 1;
    if (digitalRead(buttonApin) == HIGH) {
      veritrich1 = 2;
      Serial.println(veritrich1);
    }
    if (digitalRead(buttonBpin) == HIGH) {
      veritrich2 = 2;
    }
    if (digitalRead(buttonApin) == LOW) {
      if (veritrich1 == 2) {
        score1 += 1;
        veritrich1 = 1;
      }
    }
    if (digitalRead(buttonBpin) == LOW) {
      if (veritrich2 == 2) {
        score2 += 1;
        veritrich2 = 1;
      }
    }
    if (chrono == 30) {
      arcade = 11;


    }
  }
  if (arcade == 11) {
    lcd.setCursor(0, 0);
    lcd.print("p1:");
    lcd.print(score1);
    lcd.print("pts!          ");
    lcd.setCursor(0, 1);
    lcd.print("p2:");
    lcd.print(score2);
    lcd.print("pts!          ");
  }
  Serial.println(tempCpublic);
  if (arcade == 12) {




  }
}



the problems:
1: making an if with words: solved
2:max7219 dont show what i want anymore
3: Making that rfid can make that a card when you pass it it says welcome "card name"
4: the pression buttons count 1 of ten of my press
5: im thinking because i forgot

thank you

A little bit of research on the subject of string parsing should enlighten you.

However, if you only have a few commands, then you can store each received character in a buffer until you detect a CR (carriage return) and/or LF (line feed). Then you could use the strncmp() to compare the initial part of the received command.

1 Like

It is easier for us if you make a small sketch that shows the problem.
For which Arduino board is it ? A command line interpreter can use a lot of memory.

Are you familiar with the old 'C' functions, such as strcmp(), strcpy(), and so on ? Or do you prefer the Arduino String object ?

Consider making this thread the only thread on the program. They don't like cross-posting.
Also, if you list all of your issues and post your code any underlying issues can be found and save everyone a lot of time and potential headache.

@marsuwill75 , it may help if you can give us examples of your commands.

If you want an example of ONLY this funcion there is:

String serialread;

void setup() {
Serial.begin(9600);

void loop() {

while (Serial.available()) {
serialread = Serial.readString();
if (serialread == command) {
(execute command);
}

there are not all the } but its because i copied the inportant things

The command examples I was referring to were the ones you are going to type in on the serial monitor.

Maybe:
LED ON
LED OFF
etc.

Consider using a command table and accompanying command function table:

//create a type called pFunc_t we can use to point
//to a function that takes nothing and returns nothing
//(e.g. void func( void )
typedef void (*pFunc_t)( void );

#define NUM_CMDS        3           //number of commands supported
#define RX_BUFF_SIZE    20          //size of receive buffer
#define BLINK_TIME      300ul       //interval between LED toggles in blink mode

//tidily enumerate the LED modes
typedef enum
{
    MODE_OFF,
    MODE_ON,
    MODE_BLINK
    
}e_Modes_t;

//prototypes for the LED mode functions
void Blink( void );
void On( void );
void Off( void );

//valid commands. we compare the received
//string to these
const char *pszCommands[] = 
{
    "Blink",
    "On",
    "Off"  
};

//this is an array of pointers to functions
//of type pFunc_t (see above)
//the order of the function addresses must
//match the order of the commands in pszCommands
pFunc_t pgrFuncs[NUM_CMDS] = 
{
    &Blink,     //address of the blink function
    &On,        //address of the on function
    &Off        //address of the off function
    
};

const uint8_t pinLED = LED_BUILTIN;

uint8_t
    modeLED = MODE_OFF;
char
    szRxBuff[RX_BUFF_SIZE];
uint32_t
    timeNow,
    timeBlink;    

void setup( void )
{   
    Serial.begin(115200);
    pinMode( pinLED, OUTPUT );
    digitalWrite( pinLED, LOW );
    
}//setup

void loop( void )
{   
    Receive();
    DoLED();
     
}//loop

void DoLED( void )
{
    //what is the mode of the LED?
    switch( modeLED )
    {
        case    MODE_OFF:
        case    MODE_ON:
            //do nothing for these modes as the function
            //turns the LEDs on or off
        break;
        
        case    MODE_BLINK:
            //blnk; toggle state every BLINK_TIME mS
            timeNow = millis();
            if( (timeNow - timeBlink) >= BLINK_TIME )
            {
                timeBlink = timeNow;
                digitalWrite( pinLED, digitalRead( pinLED ) ^ HIGH  );
                
            }//if
            
        break;
        
    }//switch
    
}//DoLED

void Receive( void )
{
    static uint8_t
        idx = 0;

    //i don't use String objects. You should be able to convert this
    //to work with them if you like
    if( Serial.available() > 0 )
    {
        //rx the char
        uint8_t ch = Serial.read(); 
        //newline indicates end of command
        if( ch == '\n' )
        {
            //put a NULL character there (null-terminated string)
            szRxBuff[idx] = '\0';
            //reset the buffer index
            idx = 0;
            //go see if there's a match for this command
            ParseCommand();
            
        }//if
        else
        {
            //otherwise, put character in buffer
            szRxBuff[idx++] = ch;
            //make sure pointer doesn't point off end
            //of out buffer
            if( idx == RX_BUFF_SIZE-1 )
                idx--;
                
        }//else
        
    }//if
    
}//Receive

void ParseCommand( void )
{
    uint8_t
        idx = 0;

    do
    {
        //look for a string match
        //for C-strings, the strcmp() function returns '0' if the strings are the same
        if( strcmp( szRxBuff, pszCommands[idx] ) == 0 )
        {
            //match found at index 'idx'; look into the command function table
            //and run the function pointed to by idx
            pgrFuncs[idx]();
            
            //indicate we did it
            Serial.print( "Command " ); Serial.print( szRxBuff ); Serial.println( " recognized." );

            //done
            return;
            
        }//if

        //no match; try again
        idx++;
        
    }while( idx < NUM_CMDS );   //only try as many times as there are entries in the command table

    //if we get here we came to the end of the command table
    //and saw no match
    Serial.println( "Command not recognized." );       
    
}//ParseCommand

void Blink( void )
{
    //set the mode to blink the LED
    modeLED = MODE_BLINK;
    
}//Command

void On( void )
{
    //turn on the LED & set the mode to 'on'
    digitalWrite( pinLED, HIGH );
    modeLED = MODE_ON;
    
}//On

void Off( void )
{
    //turn off the LED & set the mode to 'off'
    digitalWrite( pinLED, LOW );
    modeLED = MODE_OFF;
    
}//Off

i can't because i erased all links in my sketch and it says "sorry new users can only post 2 links"

That's probably because you're not using code tags. They are in the menu of your reply box and look like this </>
Check out this post:

Then please try again :slight_smile:

if (serialread.startsWith("command"))

@marsuwill75 I think this is what you are looking for, but I would not use it.

// Warning : This is a bad example ! I don't like it.

String myInputString;

void setup() 
{
  pinMode( 13, OUTPUT);
  Serial.begin( 115200);
  Serial.setTimeout( 100);        // not failsafe, because input stream is unknown
  Serial.println( "Type ON or OFF for the led");
}

void loop()
{
  if( Serial.available() > 0)
  {
    myInputString = Serial.readString(); // waits for more input and stops with the timeout

    myInputString.trim();                // get rid of Carriage Return and LineFeed
    myInputString.toLowerCase();         // everything to lowercase, to allow upper and lower case

    if( myInputString == "on")
    {
      digitalWrite( 13, HIGH);
    }
    else if( myInputString == "off")
    {
      digitalWrite( 13, LOW);
    }
  }
}

This sketch in Wokwi:

Type 'on' or 'off' in the input field and see the little onboard led turn on and off.

it's working, thanks