Code...drawing will take me longer due to disability. Not looking for sympathy, just understanding.
//LightBox
//Sketch to control a lightbox consisting of 144 WS2812B LEDs
//arranged in a 12x12 grid
//external controls will allow full control of RGB output
//for the whole set of LEDs and for a selected individual LED.
//by Nigel Coxon 13/4/2018
#include "SevSeg.h"
#include <Adafruit_NeoPixel.h>
#define N_LEDS 144 //LEDS in grid
#define PIN 8 //output pin for LED data
long lastread = millis();
SevSeg sevseg;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
int potPin = A0; // select the input pin for the potentiometer (currentyl only using one)
int Aval1 = 0; // variable to store the value coming from the sensor
int Rval = 0; // Red - only value currently actively controllable
int Gval = 0; // Green
int Bval = 0; // Blue
void setup() {
strip.setBrightness(255);
strip.begin();
int pixelarray[12][12] = {
{ 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,},
{ 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11,},
{ 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,},
{ 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35,},
{ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,},
{ 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59,},
{ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82,},
{ 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83,},
{ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,},
{ 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107,},
{ 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,},
{ 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,}
};
// The pixelarray is used in the form "pixelarray[x][y]" to return the sequential pixel number in the strip.
// The double zero at the start is intentional as I have one damaged pixel due to a soldering mistake.
int lightpitch = 1; //sometimes I use a grid of 30-pitch LEDS. Changing lightpitch to 2 simulates this (lights every other LED)
byte numDigits = 3; //for the displays
byte digitPins[] = {10, 11, 12}; //for thie digits on the display
byte segmentPins[] = {22, 26, 34, 30, 28, 24, 36, 32}; //pins used for each segment (a,b,c,d,e,f,g, dp)
bool resistorsOnSegments = true; //I don't know what this does
bool updateWithDelaysIn = true; //I don't know what this does
byte hardwareConfig = COMMON_ANODE; //Yay, I know I have CA displays!
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
Serial.begin(9600);
delay(1000);
}
void loop() {
int p = 0;
// intialise pixels woth current values
for (p = 0; p < N_LEDS; p++) {
strip.setPixelColor(p, Rval, Gval, Bval);
}
strip.show();
// read the value from the sensor
Aval1 = analogRead(potPin);
//convert from 0-1023 (5v) to 0-255
Rval = Aval1 * 0.25;
//update pixels with new value
for (p = 0; p < N_LEDS; p++) {
strip.setPixelColor(p, Rval, Gval, Bval);
}
strip.show();
//update the LCD display with the new value
sevseg.setNumber(Rval, 0);
sevseg.refreshDisplay();
Serial.print("Value;");
Serial.println(Aval1);
}
If you think the code is bad wait until yo usee the connection diagram...