issue with random selected number

Hello to all, I have an issue as follows;

I have a breadboard project with 3 LEDs and a switch.
The LEDS are wired into pins 2,5 and 8.
I am using a random selected number between 2 and 5.
When 2 is random selected it switched on the LED at pin 2.
I would like to use this selection as an input to switch on the other LEDS at pins 5 and 8.
I'm sure it's a basic error but the problem is that both LEDs at pins 5 and 8
are switching on and off constantly due to the delay function. I am using an "if" statement with the switch and a variable assigned to the LED at pin 2 going high but I'm having no joy.

Any help would be greatly appreciated.

Here is the code I'm using.

i

nt LED_1 = 2;
int LED_2 = 5;
int LED_3 = 8;
byte pushButton = 12;
// A long variable to hold a random number.
long randomNumber;

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);
  Serial.println("start a new sequence of Random Numbers");
  pinMode (LED_1, OUTPUT);
  pinMode (LED_2, OUTPUT);
  pinMode (LED_3, OUTPUT);
  pinMode (pushButton, INPUT);
  randomSeed(analogRead(A0));
}

void loop() {
  // put your main code here, to run repeatedly:
  boolean power =  digitalRead(pushButton);
   

  randomNumber = random(2, 5);
  Serial.print(" THE RANDOM NUMBER IS ");
  Serial.println(randomNumber);

  digitalWrite(randomNumber, HIGH);
  
boolean lightOn = (LED_1,HIGH);


  if (power == 1 && lightOn == 1) {
    digitalWrite(LED_2, HIGH);
    digitalWrite(LED_3, HIGH);
   delay(1000); 
  }
  if (lightOn == LOW) {
    digitalWrite (LED_2, LOW);
    digitalWrite(LED_3, LOW);
    
  }


  digitalWrite(LED_1, LOW);
  digitalWrite (LED_2, LOW);
  digitalWrite(LED_3, LOW);
  delay(1000);
}

What are you expecting this line to do?

boolean lightOn = (LED_1,HIGH);

Thanks for the prompt reply,

I thought I could use a variable assigned to LED_1, (when triggered by the random number 2 to go high) and then use this variable as part of a condition in an "if" statement to trigger the other 2 LEDs,
my thoughts were that this " lightOn" variable would only be true when the LED_1 is high.

Sorry but I'm not sure what you're getting at there.

Also re the random number, random(2, 5); generates a number from 2 (inclusive) to 5 (exclusive), it can only be 2, 3 or 4. (edit: what does the serial print of the number show?)

Since your LEDs are on pins 2, 5 and 8, your digitalWrite(randomNumber, HIGH); is only ever light the LED on pin 2, and otherwise try to light up pins 5 and 8 oops I mean 3 and 4 which are a) inputs by default and b) have no LEDs.

yes, that's the issue. This is a project that will develop further over time , I hope!!

I need to have the LEDs on pins 2, 5 and 8 . I will have 12 LEDs ( pins 2 - 13) in total with 3 of them used for the switches (pins 11-13)
I will have a total of 9 LEDs in a grid formation.
These 9 LEDs will illuminate but not all together.
I will have 2 switches.

Each switch will call on some of the same LEDs to be used but in a different formation, hence the 2,5, and 8 pins being used for this grid formation. The random number call re. random (2,5) will , as you say generate a 2,3, or 4. The random number 2 happens to be the the part of the grid with LEDs at pins 5 and 8 .

I will use the second switch to call on a different part of the program which will also use a random number generated but with a different range of numbers. pins 2 or 5,or 8 will, I hope be turned on by a LED in their respective part of the grid. That's why I need to use the LED ( which is triggered by the random number) to
act as a trigger for the LEDs on its part of the grid.

at the Mo i'm trying to develop what I consider the difficult part of the project.

mechup:
yes, that's the issue.

What is, that you can't generate a 5 or 8 instead of 3 and 4?

If that's the issue it's easy to fix with an "if"... if randomnumber =3 pinnumber =5 kind of thing.

But, I really don't understand what you're trying to describe.

I especially don't get this part:

I will have 12 LEDs ( pins 2 - 13) in total with 3 of them used for the switches (pins 11-13)

That sounds like you want pins 11, 12 and 13 to have LEDs (be outputs) and switches (be inputs).

Sorry!!! yes , the LEDs will be on pins 2-13, and the switches will be on pins A1 , A2. my apologies.

I'm half way through an online course (program electronics academy) and decided to set myself a project.

i will create the "if " statement as you suggest and hopefully get over this obstacle.!!! ...............................................................................................

YES!!!!!! That worked!!! every day is a day for school!!!

Thanks once again.