Boolean list how do I finish for void loop

I'm trying to make a Boolean list for a project using LEDs and I don't now how to finish the rest of the code, if you know of any guides that could help that would be great.

There are 16 LEDs and I am linking them to a keypad.

#include <Keypad.h>

int latchPin = 12;
int clockPin = 11;
int dataPin = 13;

const byte ROWS = 4; 
const byte COLS = 4; 
char Key = 0;

char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6}; 
byte colPins[COLS] = {5, 4, 3, 2}; 


bool LEDlist[]={false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,}// This is the bool list 

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); 

void setup(){
 
{
 
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
}

  Serial.begin(9600);


}


  
void loop(){


  char customKey = customKeypad.getKey();
  
LEDlist[]={false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false,}

if(customKeypad.isPressed('1')){
   Serial.println("1");
   LEDlist[0] = true   
  }
  if(customKeypad.isPressed('2')){
   Serial.println("2");
   LEDlist[1] = true
  }
   if(customKeypad.isPressed('3')){
   Serial.println("3");
   LEDlist[2] = true
  }
   if(customKeypad.isPressed('4')){
   Serial.println("4");
   LEDlist[3] = true
  }
   if(customKeypad.isPressed('5')){
   Serial.println("5");
   LEDlist[4] = true
  }
   if(customKeypad.isPressed('6')){
   Serial.println("6");
   LEDlist[5] = true
  }
   if(customKeypad.isPressed('7')){
   Serial.println("7");
   LEDlist[6] = true
  }
   if(customKeypad.isPressed('8')){
   Serial.println("8");
   LEDlist[7] = true
  }
   if(customKeypad.isPressed('9')){
   Serial.println("9");
   LEDlist[8] = true
  }
   if(customKeypad.isPressed('0')){
   Serial.println("0");
   LEDlist[9] = true
  }
   /*if ("A" == customKeypad.getKey()){ 
   Serial.println("A");                    
   LEDlist[10] = true                      
  }                                        
   if ("B" == customKeypad.getKey()){      
   Serial.println("B");                    
   LEDlist[11] = true                      
  }                                       
   if ("C" == customKeypad.getKey()){      
   Serial.println("C");                    
   LEDlist[12] = true
  }
   if ("D" == customKeypad.getKey()){
   Serial.println("D");
   LEDlist[13] = true
  }*/
   if(customKeypad.isPressed('#')){
   Serial.println("#");
   LEDlist[14] = true
  }
   if(customKeypad.isPressed('*')){
   Serial.println("*");
   LEDlist[15] = true
   }
   
   {
  char keypressed = customKeypad.getKey(); 
  if (keypressed != NO_KEY) 
    { 
     Serial.println(keypressed); 
    } 
   }
}

sketch_apr11a.ino (4.48 KB)

You have LEDlist defined globally and again local to the loop() function. This can cause great confusion and is a REALLY BAD THING to do!

I'm trying to make a Boolean list for a project using LEDs

Perhaps you have a different meaning for list that I do, but I can not imagine how to make a list, of any type, with LEDs.

void setup(){
 
{
 
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT); 
  pinMode(clockPin, OUTPUT);
}

Why are the pinMode calls in a useless set of braces?

UnterD0G:
I'm trying to make a Boolean list for a project using LEDs and I don't now how to finish the rest of the code, if you know of any guides that could help that would be great.

There are 16 LEDs and I am linking them to a keypad.

The code you posted needs a bit of work before it will compile successfully, but the main problem is you haven't even stated what you are attempting to do. Your code has made an array of boolean variables to represent the LEDs, but only you know what you intend to do with that.

my bad I'm making a MIDI launchpad using a 4x4 keypad and 16 LEDs and for my list I plan on making it so when I click a key on my keypad I will update the linked false in the list from false to true and the linked LEDs to turn on on true. if that makes it clearer as to what I'm trying to do. this is my first big project with Arduino so I'm trying to learn c++.

You need an array of struct instances. Define a struct with the LED pin number and the pin state.

Each time there is a key press, find the corresponding entry in the array, and change the pin state. Then, apply the changed state to the corresponding pin.

vaj4088:
You have LEDlist defined globally and again local to the loop() function.

Ignoring for the moment the fact that the declaration is wrongly written, as is the attempt in loop() to set the values of the array elements, the LEDlist array is actually only declared once as global

UKHeliBob is correct. I am sorry. I let the array "initializer" fool me, but that is no excuse.

It sounds like you might be better starting of with an array[] of struct{} for each position.
Then a switch()-case: block to perform the activities.

While this may sound complicated now, wait until you have to dynamically add 16 MIDI actions to the 16 buttons.

A little exploration before you press RUN will always help identify a better strategy.

thanks for the help I'll look into the array I have a friend who was telling me the same thing about it I think I have a idea of what to do now.