Reactive RBG lights and analog proximity matrix array

I've been trying to make a reactive RGB LED table with analog proximity sensors, and it works but ill need a lot more inputs than i can get on the arduino. I'm having issues with the writing the code for my sensor array.

My code for tresting

//[blue, red, green] my actuall color order

#include <FastLED.h>

#define LED_PIN     9
#define NUM_LEDS    3
#define COLOR_ORDER RGB

CRGB leds[NUM_LEDS];

void setup() {
//delay(1000);
  FastLED.addLeds<WS2812, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);

  Serial.begin (9600);
}

void loop() {
 int sensorValue0 = analogRead(A0);
  int Hue0;
   Hue0 = map(sensorValue0, 0, 1023, 0, 255);
 int sensorValue1 = analogRead(A1);
  int Hue1;
   Hue1 = map(sensorValue1, 0, 1023, 0, 255);
 int sensorValue2 = analogRead(A2);
  int Hue2;
   Hue2 = map(sensorValue2, 0, 1023, 0, 255);  
  
  
  for(int i = 0; i < NUM_LEDS; i++){
    Hue0 = map(sensorValue0, 0, 1023, 0, 255);
  leds[0] = CHSV(Hue0, 255, 128);
   FastLED.show();
  leds[1] = CHSV(Hue1, 255, 128);
    FastLED.show();
  leds[2] = CHSV(Hue2, 255, 128);
    FastLED.show();
  }
  //Serial.println(Hue0);
  //Serial.println(Hue1);
  //Serial.println(Hue2);


}

With this I can control each LED individualy, witch each sensor. serial print is only so i can see sensor values during prototyping.

I tried modyfing it by adding a 2x2 matrix istead of individual senors, I want final product to be 12x12 or easly scalable.

For the future im planing to add sound spectrum meter so it can switch between sensor mode to sound pectrum mode.

Thanks in advance.

attempt at matrix code, dont know how to get the output i want :frowning:

//[blue, red, green]

#include <FastLED.h>

#define LED_PIN     9
#define NUM_LEDS    3
#define COLOR_ORDER RGB

//int row[1] = A0;    (faild idea on hold)
//int row[2] = A1;

byte rows[] ={A0,A1};
const int rowCount = sizeof(rows)/sizeof(rows[0]);

byte cols[] = {2,3};
const int colCount = sozeof(cols)/sizeof(cols[0]};


CRGB leds[NUM_LEDS];

void setup() {
  delay(1000);
  Serial.begin (9600);
  
  for(int x=0; x<rowCount; x++) {
        Serial.print(rows[x]); Serial.println(" as input");
        pinMode(rows[x], INPUT);
    }
 
    for (int x=0; x<colCount; x++) {
        Serial.print(cols[x]); Serial.println(" as input-pullup");
        pinMode(cols[x], INPUT_PULLUP);
    }
  
  FastLED.addLeds<WS2812, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);

 
}



void readMatrix() {
    for (int colIndex=0; colIndex < colCount; colIndex++){
      byte curCol = cols[colIndex];
      pinMode(curCol, OUTPUT):
      digitalWrite(curCol, LOW);
    
    
    for (int rowIndex=0; rowIndex<rowCount; rowIndex++){
      byte rowCol = row[rowIndex];
      pinMode(rowCol, INPUT_PULLUP);
      sens[colIndex][rowIndex] = analogRead(rowCol);
      pinMode(rowCol, INPUT);
    }
    pinMode(curCol, INPUT)
    }
  }

  void writeMatrix() {
    
    








 void loop() {
          //   (i know it needs change i didnt get this far yet)
 int Hue0;
 int Hue1;
 int Hue2;
 
 int sensorValue0 = analogRead(A0);
     Hue0 = map(sensorValue0, 0, 1023, 0, 255);
 int sensorValue1 = analogRead(A1);
   Hue1 = map(sensorValue1, 0, 1023, 0, 255);
 int sensorValue2 = analogRead(A2);
    Hue2 = map(sensorValue2, 0, 1023, 0, 255);  
  
  
  for(int i = 0; i < NUM_LEDS; i++){
    Hue0 = map(sensorValue0, 0, 1023, 0, 255);
  leds[0] = CHSV(Hue0, 255, 128);
   FastLED.show();
  leds[1] = CHSV(Hue1, 255, 128);
    FastLED.show();
  leds[2] = CHSV(Hue2, 255, 128);
    FastLED.show();
  }
  //Serial.println(Hue0);
  Serial.println(Hue1);
  //Serial.println(Hue2);


}
const int colCount = sozeof(cols)/sizeof(cols[0]};

I don't think so

Thanks for pointing it out but that was not the issue i wanted help with, all matrix tutorials example are with keypads or led matrix. :frowning:

that was not the issue i wanted help with

Maybe not, but as presented the code will not compile. I assume that you don't want to know about other errors in the code

I made the corrections and little chages

//[blue, red, green]

#include <FastLED.h>

#define LED_PIN     9
#define NUM_LEDS    3
#define COLOR_ORDER RGB

//int row[1] = A0;
//int row[2] = A1;

byte rows[] ={A0,A1};
const int rowCount = sizeof(rows)/sizeof(rows[0]);

byte cols[] = {2,3};
const int colCount = sizeof(cols)/sizeof(cols[0]);

byte ledPos[colCount][rowCount];

CRGB leds[NUM_LEDS];

void setup() {
  delay(1000);
  Serial.begin (9600);
  
  for(int x=0; x<rowCount; x++) {
        Serial.print(rows[x]); Serial.println(" as input");
        pinMode(rows[x], INPUT);
    }
 
    for (int x=0; x<colCount; x++) {
        Serial.print(cols[x]); Serial.println(" as input-pullup");
        pinMode(cols[x], INPUT_PULLUP);
    }
  
  FastLED.addLeds<WS2812, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);

 
}



void readMatrix() {
   int sens;
    for (int colIndex=0; colIndex < colCount; colIndex++){
      byte curCol = cols[colIndex];
      pinMode(curCol, OUTPUT);
      digitalWrite(curCol, LOW);
    
    
    for (int rowIndex=0; rowIndex < rowCount; rowIndex++){
      byte rowCol = rows[rowIndex];
      pinMode(rowCol, INPUT_PULLUP);
      ledPos[colIndex][rowIndex] = analogRead(rowCol);
      pinMode(rowCol, INPUT);
    }
    pinMode(curCol, INPUT);
    }
  }

  void writeMatrix() {
    
       // Please help here
  }







 void loop() {  //old  version of the code (might recycle it at some ponit so i left it for now)
    
 int Hue0;
 int Hue1;
 int Hue2;
 
 int sensorValue0 = analogRead(A0);
     Hue0 = map(sensorValue0, 0, 1023, 0, 255);
 int sensorValue1 = analogRead(A1);
   Hue1 = map(sensorValue1, 0, 1023, 0, 255);
 int sensorValue2 = analogRead(A2);
    Hue2 = map(sensorValue2, 0, 1023, 0, 255);  
  
  
  for(int i = 0; i < NUM_LEDS; i++){
    Hue0 = map(sensorValue0, 0, 1023, 0, 255);
  leds[0] = CHSV(Hue0, 255, 128);
   FastLED.show();
  leds[1] = CHSV(Hue1, 255, 128);
    FastLED.show();
  leds[2] = CHSV(Hue2, 255, 128);
    FastLED.show();
  }
  //Serial.println(Hue0);
  //Serial.println(Hue1);
  //Serial.println(Hue2);


}