Lcd text turning on before sensor

Hello, I am working on a project where you open a briefcase and the lcd screen starts showing text a few seconds after light has hit a sensor. (To make it look like as you open the briefcase the computer starts up.) The code for the 'boot up' works by itself, but when you add the other parts it does not. (also, the lcd is only changing the top row and not the bottom. The bottom stays 'Black Box" the whole time)

Here is the code:

#include <Wire.h>
#include <rgb_lcd.h>
int Lightsensor = A1;
int threshold;
int sensorValue;
int pressed;
rgb_lcd lcd;

const int colorR = 15 ;
const int colorG = 30;
const int colorB = 0;
const int knob = A2;

void setup() 
{
  Serial.begin (9600);
 pinMode(knob, INPUT);
  pinMode(Lightsensor, INPUT);
  threshold = 1;
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    
    lcd.setRGB(colorR, colorG, colorB);
}
void loop() 
{
  
  sensorValue= analogRead(Lightsensor);
  

if(sensorValue>threshold) {
     delay(2500);
    lcd.setCursor(1, 0);
    lcd.print("Multipurpose");
    lcd.setCursor(1, 1);
    lcd.print("Black Box             ");
    

    delay(10);
}
    
else { 

lcd.setCursor(1, 0);
   lcd.print("               ");
    lcd.setCursor(1, 1);
    lcd.print("               ");
}

{  
  
  if (sensorValue > 12 && sensorValue <337)

sensorValue = analogRead(knob);
Serial.print("KnobValue = ");  // Say Knob Value =
Serial.println(sensorValue); 


    lcd.setCursor(0, 0);
   lcd.print(" Radio Pulse  ");
    lcd.setCursor(1, 1);
    lcd.print("Detector");
}
{
  if (sensorValue < 12 )
lcd.setCursor(0, 0);
    lcd.print(" Multipurpose  ");
    lcd.setCursor(1, 1);
    lcd.print("Black Box");
  
}
{   
  if (sensorValue > 337 && sensorValue <674)
  lcd.setCursor(1, 0);
    lcd.print("Code Cracker ");
    lcd.setCursor(1, 1);
    lcd.print("        ");
}
{
  if (sensorValue > 674 && sensorValue <1011)
  
  lcd.setCursor(0, 0);
    lcd.print("!Self Distruct!");
    lcd.setCursor(1, 1);
    lcd.print("Black Box       ");
}
{
  lcd.setCursor(1, 1);
    
}
}


 

    

The problem is here

    if (sensorValue > 674 && sensorValue < 1011)
      lcd.setCursor(0, 0);
    lcd.print("!Self Distruct!");
    lcd.setCursor(1, 1);
    lcd.print("Black Box       ");

You forgot the curly brackets around the dependant code

ok! Thank you... will that fix the light sensor problem? I do not want any text to show up until the light sensor is over a certain point.

Also... just to make sure... where should the brackets be added?

Then don't print anything unless the light sensor is over a certain point.

isn't that the

if(sensorValue>threshold) {
     delay(2500);
    lcd.setCursor(1, 0);
    lcd.print("Multipurpose");
    lcd.setCursor(1, 1);
    lcd.print("Black Box             ");
    

    delay(10);
}
    
else { 

lcd.setCursor(1, 0);
   lcd.print("               ");
    lcd.setCursor(1, 1);
    lcd.print("               ");
}

{  

Fix the problem that I pointed out and come back if you have any remaining problems

Can you say specifically where to put the brackets ?It still isn't working

Put the brackets round the code that you want to run when

if (sensorValue > 674 && sensorValue < 1011)

is true, just like the other tests and code blocks in your sketch

When I do that the text changes depending on light but it is all jumbled up.

Post your latest code in a new post

#include <Wire.h>
#include <rgb_lcd.h>
int Lightsensor = A1;
int threshold;
int sensorValue;
int pressed;
rgb_lcd lcd;

const int colorR = 15 ;
const int colorG = 30;
const int colorB = 0;
const int knob = A2;

void setup() 
{
  Serial.begin (9600);
 pinMode(knob, INPUT);
  pinMode(Lightsensor, INPUT);
  threshold = 1;
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    
    lcd.setRGB(colorR, colorG, colorB);
}
void loop() 
{
  
  sensorValue= analogRead(Lightsensor);
  

if(sensorValue>threshold) {
     delay(2500);
    lcd.setCursor(1, 0);
    lcd.print("Multipurpose");
    lcd.setCursor(1, 1);
    lcd.print("Black Box             ");
    

    delay(10);
}
    
else { 

lcd.setCursor(1, 0);
   lcd.print("               ");
    lcd.setCursor(1, 1);
    lcd.print("               ");
}

{  
  
  if (sensorValue > 12 && sensorValue <337)

sensorValue = analogRead(knob);
Serial.print("KnobValue = ");  // Say Knob Value =
Serial.println(sensorValue); 


    lcd.setCursor(0, 0);
   lcd.print(" Radio Pulse  ");
    lcd.setCursor(1, 1);
    lcd.print("Detector");
}
{
  if (sensorValue < 12 )
lcd.setCursor(0, 0);
    lcd.print(" Multipurpose  ");
    lcd.setCursor(1, 1);
    lcd.print("Black Box");
  
}
{   
  if (sensorValue > 337 && sensorValue <674)
  lcd.setCursor(1, 0);
    lcd.print("Code Cracker ");
    lcd.setCursor(1, 1);
    lcd.print("        ");
}
{
  if (sensorValue > 674 && sensorValue <1011)
 { 
  lcd.setCursor(0, 0);
    lcd.print("!Self Distruct!");
    lcd.setCursor(1, 1);
    lcd.print("Black Box       ");
 }
}
{
  lcd.setCursor(1, 1);
    
}
}


 

    

I do not really care about the bottom line not changing I just need the display to show no text when there is no light and it to display the prompt with the corresponding knob values.

At what value of sensorValue do you want to start displaying text ?

At the moment you have threshold set to 1 so any value greater than 1 will display something

The sketch also has a number of redundant { } pairs which serve to confuse anyone reading the code and I just noticed that you have removed the brackets around most of the dependent code for your tests of sensorValue. Why did you do that ?

I have cleaned it up and now have this
the text works but I am getting a 'else' without previous 'if' for the light sensor part

#include <Wire.h>
#include <rgb_lcd.h>
int Lightsensor = A1;
int threshold;
int sensorValue;
int pressed;
rgb_lcd lcd;

const int colorR = 15 ;
const int colorG = 30;
const int colorB = 0;
const int knob = A2;

void setup() 
{
  Serial.begin (9600);
 pinMode(knob, INPUT);
  pinMode(Lightsensor, INPUT);
  threshold = 50;
    // set up the LCD's number of columns and rows:
    lcd.begin(16, 2);
    
    lcd.setRGB(colorR, colorG, colorB);
}
void loop() 
{
  
  sensorValue= analogRead(Lightsensor);
  

if(sensorValue>threshold) 
lcd.setCursor(0, 0);
   lcd.print(" black box 101 ");

else 

lcd.setCursor(0, 0);
   lcd.print(" black box 101 ");
   }
  //----------------------------------------------------------
 sensorValue = analogRead(knob);
Serial.print("KnobValue = ");  // Say Knob Value =
Serial.println(sensorValue); 
  
  if (sensorValue > 12 && sensorValue <337){
 lcd.setCursor(0, 0);
   lcd.print(" Radio pulse ");
    lcd.setCursor(1, 1);
    lcd.print("Detector ");
}
   else if (sensorValue < 12 ){
lcd.setCursor(0, 0);
    lcd.print(" Multipurpose  ");
    lcd.setCursor(1, 1);
    lcd.print("Black Box");
  }
  
  else if (sensorValue > 337 && sensorValue <674){
  lcd.setCursor(1, 0);
    lcd.print("Code Cracker ");
    lcd.setCursor(1, 1);
    lcd.print("           ");
  }
 else {
  lcd.setCursor(0, 0);
    lcd.print("!Self Distruct!");
    lcd.setCursor(1, 1);
    lcd.print("Black Box       ");
  }
 
    
}



 

    

If there is something interfering with the proximity sensor, the screen may not respond as excepted. The proximity sensor cannot be disabled.

void loop()
{
  sensorValue = analogRead(Lightsensor);
  if (sensorValue > threshold)
    lcd.setCursor(0, 0);
  lcd.print(" black box 101 ");
  else
    lcd.setCursor(0, 0);
  lcd.print(" black box 101 ");
}

Why aren't the code blocks for the if and else in curly brackets ?