Home LED projects LoL Shield Random LEDs flashing example

LoL Shield Random LEDs flashing example

by shedboy71

The LoL Shield is a charlieplexed LED matrix for the Arduino. The LEDs are individually addressable, so you can use it to display anything in a 9×14 grid. Scroll text, play games, display images, or anything else you want to do. It comes as a kit or an assembled board, teher are also various colour options and also an SMD example available.

The kit has 126 LEDs in total

LoL Shield

LoL Shield

random LEDs on using the LOLShield and an Arduino

Code

You will need to install the library for the LOL Shield – https://github.com/jprodgers/LoLshield

[codesyntax lang=”cpp”]

#include <avr/pgmspace.h>
#include <Charliplexing.h>

#define FREQ 30
//this is the LED matrix (14 by 9)
byte LOLARRAY[14][9];

//sets values
void set(int x, int y, int v)
{
LOLARRAY[x][y] = v;
LedSign::Set(x, y, v);
}

// returns random bit 0 or 1 baesd on value
int randBit()
{
int v = random(100);
return (v < FREQ) ? 1 : 0;
}

void randPattern(int lines = 9)
{
for (int i = 0; i < 14; i++)
{
for (int j = 0; j < lines; j++)
{
set(i,j,randBit());
}
}
}

void setup()
{
LedSign::Init();
randomSeed(analogRead(0));
}

void loop()
{
randPattern();
delay(1000);
}

[/codesyntax]
Links

LOL shield at Amazon UK

LOL Shield at Amazon

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More