# trouble displaying letters efficiently In 5x5x5 rgb led cube

Hello everyone, I recently made a 5x5x5 RGB led cube using the WS2812 leds all daisychained to eachother, now I want to display letters in the cube, but am having trouble figuring out how to do such thing. attached you find a buildplan of the cube's leds:

I am using the FASTLED library to interface with the leds.
Hope you can help me figure it out thanks in advance.

It depends what plane you want to display your letters in. The best way is to have a lookup table to translate between your display bits and the LED number.

Due to the number of possible display orientations this requires a multi dimensional array.

I don't see the need for a multidimensional array. The x,y,z coordinates can be translated into the led number n with a simple algorithm.

Let's assume z is the layer number, but starting from zero not one. x is left to right in your diagram.

For odd values of y, you must subtract x from 4:

if (y & 1) x = 4 - x;

Then you calculate n:

n = z * 25 + y * 5 + x;

Grumpy_Mike:
It depends what plane you want to display your letters in. The best way is to have a lookup table to translate between your display bits and the LED number.

Due to the number of possible display orientations this requires a multi dimensional array.

Ive got it to work, thanks. If anyone is interested here is the code:

``````#include <FastLED.h>

#define DATA_PIN    5
#define NUM_LEDS    25
CRGB leds[NUM_LEDS];

byte VLayer1[] = {0, 1, 2, 3, 4, 25, 26, 27, 28, 29, 50, 51, 52, 53, 54, 75, 76, 77, 78, 79, 100, 101, 102, 103, 104};
byte VLayer2[] = {9, 8, 7, 6, 5, 34, 33, 32, 31, 30, 59, 58, 57, 56, 55, 84, 83, 82, 81, 80, 109, 108, 107, 106, 105};
byte VLayer3[] = {10, 11, 12, 13, 14, 35, 36, 37, 38, 39, 60, 61, 62, 63, 64, 85, 86, 87, 88, 89, 110, 111, 112, 113, 114};
byte VLayer4[] = {19, 18, 17, 16, 15, 44, 43, 42, 41, 40, 69, 68, 67, 66, 65, 94 , 93 , 92 , 91, 90, 119, 118, 117, 116, 115};
byte VLayer5[] = {20, 21, 22, 23, 24, 45, 46, 47, 48, 49, 70, 71, 72, 73, 74, 95, 96, 97, 98, 99, 120, 121, 122, 123, 124};

byte HLayer1[] = {0, 1, 2, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, 19, 18, 17, 16, 15, 20, 21, 22, 23, 24};
byte HLayer2[] = {25, 26, 27, 28, 29, 34, 33, 32, 31, 30, 35, 36, 37, 38, 39, 44, 43, 42, 41, 40, 45, 46, 47, 48, 49};
byte HLayer3[] = {50, 51, 52, 53, 54, 59, 58, 57, 56, 55, 60, 61, 62, 63, 64, 69, 68, 67, 66, 65, 70, 71, 72, 73, 74};
byte HLayer4[] = {75, 76, 77, 78, 79, 84, 83, 82, 81, 80, 85, 86, 87, 88, 89, 94, 93, 92, 91, 90, 95, 96, 97, 98, 99};
byte HLayer5[] = {100, 101, 102, 103, 104, 109, 108, 107, 106, 105, 110, 111, 112, 113, 114, 119, 118, 117, 116, 115, 120, 121, 122, 123, 124};

byte A[] = {100, 0, 100, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0};
byte B[] = {100, 0, 100, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0};
byte C[] = {100, 0, 100, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0};
byte D[] = {100, 0, 100, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0};
byte E[] = {100, 0, 100, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0};
byte F[] = {100, 0, 100, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0};
byte G[] = {100, 0, 100, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0};
byte H[] = {100, 0, 100, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1};
byte I[] = {100, 0, 100, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0};
byte J[] = {100, 0, 100, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1};
byte K[] = {100, 0, 100, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1};
byte L[] = {100, 0, 100, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0};
byte M[] = {100, 0, 100, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0};
byte N[] = {100, 0, 100, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1};
byte O[] = {100, 0, 100, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0};
byte P[] = {100, 0, 100, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0};
byte Q[] = {100, 0, 100, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0};
byte R[] = {100, 0, 100, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0};
byte S[] = {100, 0, 100, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1};
byte T[] = {100, 0, 100, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1};
byte U[] = {100, 0, 100, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1};
byte V[] = {100, 0, 100, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1};
byte W[] = {100, 0, 100, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1};
byte X[] = {100, 0, 100, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1};
byte Y[] = {100, 0, 100, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1};
byte Z[] = {100, 0, 100, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1};
byte DASH[] = {100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
byte COL[] = {100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0};
byte EMPTY[] = {100, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
byte FULL[] = {100, 0, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
byte SMILE[] = {100, 0, 100, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0};
byte COLDOT[] = {100, 0, 100, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0};
byte CHECK[] = {100, 0, 100, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
byte CHECK2[] = {100, 0, 100, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0};
byte DOT[] = {100, 0, 100, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

const byte* levels[] = {VLayer1, VLayer2, VLayer3, VLayer4, VLayer5, HLayer1, HLayer2, HLayer3, HLayer4, HLayer5};
byte* letters[] = {A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, DASH, COL, EMPTY, FULL, SMILE, COLDOT, CHECK, CHECK2, DOT};

CRGB CRGBarray[25];
int Delay = 1000;
int Red, Green, Blue, Number;

void setup() {

Serial.begin(115200);
FastLED.show(CRGB::Black);
}
void loop() {
if (Serial.available() > 0) {
int plane = Serial.parseInt();
int letter = Serial.parseInt();
int Red = Serial.parseInt();
int Green = Serial.parseInt();
int Blue = Serial.parseInt();
Serial.print("Plane: ");
Serial.println(plane);
Serial.print("Letter: ");
Serial.println(letters[letter][]);
Serial.print("Red: ");
Serial.println(Red);
Serial.print("Green: ");
Serial.println(Green);
Serial.print("Blue: ");
Serial.println(Blue);
Setplane(plane, letter, Red, Green, Blue);
//delay(Delay);
}
}
void Setplane(int pane, char Letter, int R, int G, int B) {
letters[Letter][0] = R;
letters[Letter][1] = G;
letters[Letter][2] = B;
Setletter(Letter, pane);
}
void Setletter(int curletter, int curheight) {
int counter = 0;
for (int lednum = 0; lednum < NUM_LEDS; lednum++) {
setled(curheight, lednum, Red = letters[curletter][0] * letters[curletter][counter + 3], Green = letters[curletter][1] * letters[curletter][counter + 3], Blue = letters[curletter][2] * letters[curletter][counter + 3]);
/*Serial.println(counter);
Serial.println(Red);
Serial.println(Green);
Serial.println(Blue);
Serial.println();
//delay(Delay);*/
counter++;
}
}

void setled(int Currentheight, int Lednumber, int Redcolour, int Greencolour, int Bluecolour) {
CRGBarray[Lednumber].red = Redcolour;
CRGBarray[Lednumber].green = Greencolour;
CRGBarray[Lednumber].blue = Bluecolour;
leds[levels[Currentheight][Lednumber]] = CRGBarray[Lednumber];
/*Serial.println(Lednumber);
Serial.println(CRGBarray[Lednumber]);*/
// Show the leds
FastLED.show();
}
``````