Here's an animated gif of my Arduino-powered 32x16 LED screen. I wired this up using the Adafruit tutorial at https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/wiring-the-16x32-matrix
The code to generate the spiral. Note this is unoptimized. You can probably do it better. The basic nugget to get the spiral is this line: round( sqrt( pow(pNumber, 2 ))*_piCounter*PI)%2==0).
void loop()
{
initSpiral();
_piCounter += .001;
delay(200);
_globalCounter += 1;
}
void initSpiral()
{
int posX = 15;
int posY = 7;
int numberCounter = 1;
int _spacer = 1;
int legLength = 0;
//establish the first dot
//matrix.drawPixel(x, y, matrix.Color333(r, g, b));
matrix.drawPixel(posX, posY, matrix.Color333(3, 4, 5));
for (int i=1;i<17 font="" i="">17>
{
for (int k=0;k<=legLength;k++)
{
numberCounter += 1;
posX += _spacer;
testNumber(numberCounter, posX, posY);
}
for (int k=0;k<=legLength;k++)
{
numberCounter += 1;
posY -= _spacer;
testNumber(numberCounter, posX, posY);
}
legLength += 1;
for (int k=0;k<=legLength;k++)
{
numberCounter += 1;
posX -= _spacer;
testNumber(numberCounter, posX, posY);
}
for (int k=0;k<=legLength;k++)
{
numberCounter += 1;
posY += _spacer;
testNumber(numberCounter, posX, posY);
}
legLength += 1;
}
}
String _bigNumber = "01234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567012345670123456701234567";
void testNumber(int pNumber, int pX, int pY)
{
if (round( sqrt( pow(pNumber, 2 ))*_piCounter*PI)%2==0)
{
matrix.drawPixel(pX, pY, matrix.Color333(_bigNumber.charAt(pX), _bigNumber.charAt(pY), _bigNumber.charAt(_globalCounter)));
}
else
{
matrix.drawPixel(pX, pY, matrix.Color333(3, 0, 2));
}
}
Interesting note: these 32x16 panels are so incredibly bright they are painful to look at. So I'm using two sheets of paper to stop down the light, which also has a nice diffusion effect.
No comments:
Post a Comment