This tutorial will attempt to make it easier to understand how to use the shiny RGB LEDs on the back of your Gamebuino META.

General Idea

The general idea is, that the lights are just a tiny image - one with 2x4 pixels! That means you can use all the tricks, animations etc. as explained in the Images tutorial on the lights, too! The image is gb.lights, it is an rgb565 image.

Pixel layout

gb.lights being two pixels wide and four pixels high means it directly maps onto the real-life LEDs of the Gamebuino! So, the upper-left pixel controls the upper-left LED, the lower-right pixel the lower-right LED etc.

That means, to turn the LED in the bottom-right red you can do:

gb.lights.drawPixel(1, 3, RED);

1 because x-coordinate one, that is on the right side of the image, thus the gamebuino.
3 because y-coordinate three, that is all on the bottom of the image, thus the gamebuino.
Keep in mind that x- and y coordinates start at zero!

Colors

The gb.lights image being RGB565 you can use any of the pre-defined colors or make your own!

All white will mean that the LEDs are, well, all white. And all black means they are completely turned off. So, to get e.g. a dimmer red on the LEDs, you have to draw a darker red to the image.

Fading example

This example will fade the LEDs from all white to all black.

#include <Gamebuino-Meta.h>

void setup() { gb.begin(); }

void fadeToBlack() { Color c; for (uint8_t level = 255; level > 0; level--) { while(!gb.update()); gb.lights.fill(gb.createColor(level, level, level)); } while(!gb.update()); gb.lights.fill(BLACK); }

void loop() { fadeToBlack(); }

Intensity

There is no need for your game ever to have an intensity setting to set the base intensity. This is already done automatically via the home menu.