Lcd makes software stop

Hi

every time i include this in my software, its seen to hang
after i get to this point

       // WRITE TO LCD MODE 1
    lcd.backlight();  
   lcd.setCursor(0,0);
    lcd.print("Ghosthunters.dk");
    lcd.setCursor(0,1);
   lcd.print(" Sensor mode 1");
// EMF Detector for LED Bargraph v1.0
// original code/project by Aaron ALAI - aaronalai1@gmail.com
// modified for use w/ LED bargraph by Collin Cunningham - collin@makezine.com
// remodified with MCP23017 / Ir remote / Lcd Display Ed Nielsen - ed@dehulesider.dk - Project www.darkgeej.dk

#include <Wire.h>

// LCD DISPLAY
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);    // Set the LCD I2C address

  // IR REMOTE
#include "Adafruit_MCP23017.h"

int button1 = A8;
int button2 = A9;

int mode1;
int mode2;

int mode;

  // IR REMOTE
#include <IRremote.h>
int RECV_PIN = 12; //define input pin on Arduino
IRrecv irrecv(RECV_PIN);
decode_results results;

#define NUMREADINGS 15 // raise this number to increase data smoothing

int senseLimit = 5; // raise this number to decrease sensitivity (up to 1023 max)
int probePin = 0; // analog 0
int val = 0; // reading from probePin

  // int the pins
int LED1 = 2;
int LED2 = 3;
int LED3 = 4;
int LED4 = 5;
int LED5 = 6;
int LED6 = 7;
int LED7 = 8;
int LED8 = 9;
int LED9 = 10;
int LED10 = 11;
int LED13 = 13; // Software running led

  // variables for smoothing
int readings[NUMREADINGS];                  // the readings from the analog input
int index = 0;                              // the index of the current reading
int total = 0;                              // the running total
int average = 0;                            // final average of the probe reading


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

    // LCD DISPLAY
    lcd.begin(16, 2);    
    for (int i = 0; i < 3; i++)
       {
        lcd.backlight();
        delay(250);
        lcd.noBacklight();
        delay(250);
      
  }
    lcd.backlight();   
    lcd.setCursor(0, 0);
    lcd.print("Software loading");
    delay(500);
    lcd.setCursor(0, 1);
    lcd.print(" Please wait...");
    delay(2000);   

    lcd.clear();
    lcd.backlight();
    lcd.setCursor(0, 0);
    lcd.print("Software loaded");
    delay(500);
    lcd.setCursor(0, 1);
    lcd.print("We are ready..");
    delay(1000);
  lcd.clear();
    // IR REMOTE
  {
    irrecv.enableIRIn(); // Start the receiver
  }
    // set pins
    pinMode(2, OUTPUT);   
    pinMode(3, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    pinMode(10, OUTPUT);
    pinMode(11, OUTPUT);

    for (int i = 0; i < NUMREADINGS; i++)
        readings[i] = 0;                        // initialize all the readings to

}

  
void loop() {

    // IR REMOTE
 //  {
//    if (irrecv.decode(&results)) {
//        Serial.println(results.value, HEX);
//        irrecv.resume(); // Receive the next value
//    }

      // Set buttons
    {
        mode1 = digitalRead(button1);
        mode2 = digitalRead(button2);

        // Setting up the modes
        if (mode1 == HIGH) {
            mode = 1;
          
      }
        if (mode2 == HIGH) {
            mode = 2;
          
      }

        // Set inputs
        val = analogRead(probePin);    // take a reading from the probe


        // Doing the math
        if (val >= 1) {
                      // if the reading isn't zero, proceed

            val = constrain(val, 1, senseLimit);    // turn any reading higher than the senseLimit value into the senseLimit value
            val = map(val, 1, senseLimit, 1, 1023);    // remap the constrained value within a 1 to 1023 range

            total -= readings[index];                 // subtract the last reading
            readings[index] = val; // read from the sensor
            total += readings[index];                 // add the reading to the total
            index = (index + 1);                      // advance to the next index

            if (index >= NUMREADINGS)               // if we're at the end of the array...
                index = 0;                              // ...wrap around to the beginning

            average = total / NUMREADINGS;            // calculate the average
          
      }

        // VALUE MODE 1
        int SV1_1 = 105;
        int SV1_2 = 95;
        int SV1_3 = 85;
        int SV1_4 = 75;
        int SV1_5 = 65;
        int SV1_6 = 55;
        int SV1_7 = 45;
        int SV1_8 = 35;
        int SV1_9 = 25;
        int SV1_10 = 15;

        // VALUE MODE 2
        int SV_211 = 125;
        int SV2_2 = 115;
        int SV2_3 = 105;
        int SV2_4 = 95;
        int SV2_5 = 85;
        int SV2_6 = 75;
        int SV2_7 = 65;
        int SV2_8 = 55;
        int SV2_9 = 45;
        int SV2_10 = 35;


        // MODE 1

       // WRITE TO LCD MODE 1
    lcd.backlight();  
   lcd.setCursor(0,0);
    lcd.print("Ghosthunters.dk");
    lcd.setCursor(0,1);
   lcd.print(" Sensor mode 1");





        {
            if (average > SV1_10) {
                         // if the average is over 50 ...
                digitalWrite(LED10, HIGH);     // light the first LED
              
        }
            else {
                                  // and if it's not ...
                digitalWrite(LED10, LOW);      // turn that LED off
              }

            if (average > SV1_9) {
                        // and so on ...
                digitalWrite(LED9, HIGH);
              
        }
            else {
                digitalWrite(LED9, LOW);
              }

            if (average > SV1_8) {
                digitalWrite(LED8, HIGH);
              
        }
            else {
                digitalWrite(LED8, LOW);
              }

            if (average > SV1_7) {
                digitalWrite(LED7, HIGH);
              
        }
            else {
                digitalWrite(LED7, LOW);
              }

            if (average > SV1_6) {
                digitalWrite(LED6, HIGH);
              
        }
            else {
                digitalWrite(LED6, LOW);
              }

            if (average > SV1_5) {
                digitalWrite(LED5, HIGH);
              
        }
            else {
                digitalWrite(LED5, LOW);
              }

            if (average > SV1_4) {
                digitalWrite(LED4, HIGH);
              
        }
            else {
                digitalWrite(LED4, LOW);
              }

            if (average > SV1_3) {
                digitalWrite(LED3, HIGH);
              
        }
            else {
                digitalWrite(LED3, LOW);
              }

            if (average > SV1_2) {
                digitalWrite(LED2, HIGH);
              
        }
            else {
                digitalWrite(LED2, LOW);
              }

            if (average > SV1_1) {
                digitalWrite(LED1, HIGH);
              
        }
            else {
                digitalWrite(LED1, LOW);
              }
      }


  
      }}

What is wrong here? im no big programmer :wink:

What Arduino board are you using?
If Leonardo, Arduino digital pins 2 & 3 are also the I2C signal pins.
See these images for what pins are shared for various boards:

--- bill

Arduino Mega (sorry forgot)

It get to this point in the display

Ghosthunters.dk
Sensor mode 1

then it seen to be freezing

I'm assuming your LCD is working and that you mean " Sensor mode 1" shows upon the LCD?
What do you mean by "freezing"?
Nothing in the code after

    lcd.print (" Sensor mode 1");

does anything that can hang/freeze.

You are limiting the analogRead() value to values between 1 and 5 that may be difficult to see much happening depending on what is providing the reference voltage as that is a very small range since most of the potential readings will be chopped down to a value of 5.
--- bill

It Should start the mesuremt part. But the leds does nothing, and with out that Line everything Works fine

line? You showed multiple source code lines.
I'm still not clear on what the problem is and what you are changing to make it go away/work.
Maybe explain it again with a bit more detail as to what is going and what is showing up on what device (you have multiple output devices) when it is "working" vs not working.
i.e. what is the expected behavior vs the behavior you are getting.
--- bill

After cleaning up my code, the part thats everything hang , or verrryyy slow

lcd.backlight();
lcd.setCursor(0,0);
lcd.setCursor(0,1);
lcd.print(" Sensor mode 1");

You still have not clearly described what is not working as you expect.
See post #6
You need to describe EXACTLY what you are doing & seeing vs what you expect to be seeing.

--- bill