LED Matrix


The LedMatrix is a template class, that you can use in your own Java-project. It is an extension of the class LEDStrip. An LED matrix can be built from one LED strip. To do this, separate the LED strip at the desired point and place the individual strips under each other or next to each other. The individual ends can then be connected to each other with a wire. The constructor can be passed either as a rectangular matrix or a user-defined matrix with different numbers of LEDs in the individual strips. A software compatible LED strip is for example the WS28xx-chip set LED Strip.

Make sure to check if SPI is enabled in your RaspberryPI. Check the SPI Address. Default is “SPI0 MOSI” Pin (#19).


LEDMatrix Layout


A simple example on how to use the LEDMatrix-Class from the Hardware-Catalog:

System.out.println("LED matrix app started ...");
int Rows = 3;
int Columns = 4;
double brightness = 0.5;

System.out.println("Initialising the matrix");
LedMatrix ledMatrix = new LedMatrix(pi4j, Rows, Columns, brightness);

System.out.println("Setting all LEDs to Red.");

System.out.println("setting the second strip to green");
ledMatrix.setStripColor(1, LedStrip.PixelColor.GREEN);

System.out.println("Setting the third led of the third strip to Yellow");
ledMatrix.setPixelColor(2, 2, LedStrip.PixelColor.YELLOW);


System.out.println("LED matrix app done.");

Further application

The class is not yet implemented in a project.

Further project ideas

  • A suit with a sewn-on LED matrix, which can be used to display images and animations.
  • A LED-strip which can be used as a backlight of a screen. The color and brightness can change to the volume and mood of the displayed images.