9

Recently the Spike essentials set was released, including the very interesting 3x3 led matrix part:

led matrix

The matrix allows to set each individual pixel in the 3x3 array to 10 different shades of 10 different colors.

The led matrix also works with the Spike Prime set, however, it seems currently unsupported in the Mindstorms Robotics inventor set, at least there are no word blocks for it in the IDE that you can download for the set.

I'd wish to control more than one such led matrix and have purchased an additional 8 with the intention of placing them in a 3x3 array to have a larger 9x9 matrix.

The hub has however only 6 ports, so I'll need an additional hub and hub to hub communication. Unfortunately it seems that straightforward hub to hub communication is only supported in the Robotic Inventor IDE which in turn does not support the led-matrix.

What would be the easiest way to have both ? I.e. have both hub-to-hub communication and control for this new led-matrix component?

I'm willing to consider micropython solutions, but would need some pointers there:

  • what class do I need for the hub to hub communication in the python implementation with the native Spike Prime or Robotic Inventor firmware?
  • what class do I need for the led matrix control with the native Spike Prime or Robotic Inventor firmware?
  • same questions for when I would install the PyBricks micropython implementation.

Additional question, is there any way to set the color of ONE pixel without setting an entire 3x3 picture? Seems to be missing from the word blocks while setting the brightness is present...

2
+50

This isn't a direct answer to your question, but it would be one way to solve the problem. Instead of using the hubs from SPIKE or Robot Inventor, you could use the Control+ hub:

Control+ Hub

This hub unfortunately only supports 4 peripherals, so you would need three of them. This hub is not programmable, but it can be controlled over Bluetooth. You can pair up to 7 hubs to a single device this way, so you could control up to 7⨯4=28 LED matrices fairly easily.

There are a couple software options to get this running. One popular one that I've had some experience with is node-poweredup. Here's an example from the docs to control a 3x3 LED matrix attached to a Control+ hub:

const PoweredUP = require("..");

const poweredUP = new PoweredUP.PoweredUP();
poweredUP.scan(); // Start scanning for hubs

console.log("Looking for Hubs...");

poweredUP.on("discover", async (hub) => { // Wait to discover hubs

    await hub.connect(); // Connect to hub
    console.log(`Connected to ${hub.name}!`);

    const matrix = await hub.waitForDeviceByType(PoweredUP.Consts.DeviceType.TECHNIC_3X3_COLOR_LIGHT_MATRIX);

    // setMatrix accepts an array of 9 items - Either standard color values (number),
    // or Color objects with brightness (brightness values are 0 to 100%)
    // It can also accept just a single color to set all 9 lights to the same color
    matrix.setMatrix([
        // Red at 100%, green at 20%, red at 100%
        PoweredUP.Consts.Color.RED, new PoweredUP.Color(PoweredUP.Consts.Color.GREEN, 20), PoweredUP.Consts.Color.RED,
        // Green at 100%, yellow at 100%, green at 100%
        PoweredUP.Consts.Color.GREEN, PoweredUP.Consts.Color.YELLOW, PoweredUP.Consts.Color.GREEN,
        // Red at 100%, green at 20%, red at 100%
        PoweredUP.Consts.Color.RED, new PoweredUP.Color(PoweredUP.Consts.Color.GREEN, 20), PoweredUP.Consts.Color.RED,
    ]);

    hub.on("disconnect", () => {
        console.log("Hub disconnected");
    })

});

The above example would need to be extended to support a number of hubs and lights and provide some management to write large images in a coherent way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.