1.4k
This is the first of a new category, just code snippets for you to try.
First example is random LEDs on using the LOLShield and an Arduino
Code
#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);
}