MP3Trigger Library is located: https://github.com/sansumbrella/MP3Trig … ino#readme
NewSoftSerial Library is located: http://arduiniana.org/libraries/newsoftserial/
Ledcontrol Lobrary is located: http://www.wayoda.org/arduino/ledcontro … l#Download
#include <MP3Trigger.h>
#include <NewSoftSerial.h>
// TTL BlueTooth module is connected to pins 0 and 1
// MP3Trigger V2 module is connected to pins 2 and 3
NewSoftSerial MP3Trigger(3,2);
#include <LedControl.h>
#undef round
int cA[] = { B00000110,
B00001001,
B00001111,
B00001001,
B00001001 };
int cB[] = { B00000111,
B00001001,
B00000111,
B00001001,
B00000111 };
int cC[] = { B00000110,
B00001001,
B00000001,
B00001001,
B00000110 };
int cD[] = { B0000111,
B0001001,
B0001001,
B0001001,
B0000111 };
int cE[] = { B00001111,
B00000001,
B00000111,
B00000001,
B00001111 };
int cF[] = { B00001111,
B00000001,
B00000111,
B00000001,
B00000001 };
int cG[] = { B00001110,
B00000001,
B00001101,
B00001001,
B00000110 };
int cH[] = { B00001001,
B00001001,
B00001111,
B00001001,
B00001001 };
int cI[] = { B00000111,
B00000010,
B00000010,
B00000010,
B00000111 };
int cJ[] = { B00001000,
B00001000,
B00001000,
B00001001,
B00000110 };
int cK[] = { B00001001,
B00000101,
B00000011,
B00000101,
B00001001 };
int cL[] = { B00000001,
B00000001,
B00000001,
B00000001,
B00001111 };
int cM[] = { B00010001,
B00011011,
B00010101,
B00010001,
B00010001 };
int cN[] = { B00001001,
B00001011,
B00001101,
B00001001,
B00001001 };
int cO[] = { B00000110,
B00001001,
B00001001,
B00001001,
B00000110 };
int cP[] = { B00000111,
B00001001,
B00000111,
B00000001,
B00000001 };
int cQ[] = { B00000110,
B00001001,
B00001101,
B00001001,
B00010110 };
int cR[] = { B00000111,
B00001001,
B00000111,
B00000101,
B00001001 };
int cS[] = { B0,
B0,
B0,
B0,
B0 };
int cT[] = { B0,
B0,
B0,
B0,
B0 };
int cU[] = { B0,
B0,
B0,
B0,
B0 };
int cV[] = { B0,
B0,
B0,
B0,
B0 };
int cW[] = { B0,
B0,
B0,
B0,
B0 };
int cX[] = { B0,
B0,
B0,
B0,
B0 };
int cY[] = { B0,
B0,
B0,
B0,
B0 };
int cZ[] = { B0,
B0,
B0,
B0,
B0 };
LedControl lc=LedControl(12,11,10,3); //assumes only the RLD is connected
char text[] = "HELLO";
int pixelPos=27;
int scrollCount=0;
//virtual coords are 5x27; device coords are 3 panels 6x8 each
unsigned long v_grid[5]; //this will give 5x32 bits
//////////////////////////////////////////////////////////////////////////////////
void setup()
{
for(int dev=0;dev<lc.getDeviceCount();dev++)
{
lc.shutdown(dev, false); //take the device out of shutdown (power save) mode
lc.setIntensity(dev, 2); //intensity is 1-15
lc.clearDisplay(dev);
}
}
//////////////////////////////////////////////////////////////////////////////////
void loop()
{
//Scroll thru the text message one time, then go to random display
initGrid();
if (scrollCount==0)
{
scrollingText();
delay(40);
return;
}
randomDisplay();
delay(200);
}
void showGrid()
{
//copy from virt coords to device coords
unsigned char col8=0;
unsigned char col17=0;
unsigned char col26=0;
for (int row=0; row<5; row++)
{
lc.setRow(0,row, rev( v_grid[row] & 255L ) ); //device 0
lc.setRow(1,row, rev( (v_grid[row] & 255L<<9) >> 9 ) ); //device 1
lc.setRow(2,row, rev( (v_grid[row] & 255L<<18) >> 18 ) ); //device 2
if ( (v_grid[row] & 1L<<8) == 1L<<8) col8 += 128>>row;
if ( (v_grid[row] & 1L<<17) == 1L<<17) col17 += 128>>row;
if ( (v_grid[row] & 1L<<26) == 1L<<26) col26 += 128>>row;
}
lc.setRow(0, 5, col8);
lc.setRow(1, 5, col17);
lc.setRow(2, 5, col26);
}
unsigned char rev(unsigned char b)
{
//reverse bits of a byte
return (b * 0x0202020202ULL & 0x010884422010ULL) % 1023;
}
void initGrid()
{
for (int row=0; row<6; row++) v_grid[row]=0L;
}
void drawLetter(char let, int shift)
{
int *pLetter;
switch (let)
{
case 'A': pLetter=cA; break;
case 'B': pLetter=cB; break;
case 'C': pLetter=cC; break;
case 'D': pLetter=cD; break;
case 'E': pLetter=cE; break;
case 'F': pLetter=cF; break;
case 'G': pLetter=cG; break;
case 'H': pLetter=cH; break;
case 'I': pLetter=cI; break;
case 'J': pLetter=cJ; break;
case 'K': pLetter=cK; break;
case 'L': pLetter=cL; break;
case 'M': pLetter=cM; break;
case 'N': pLetter=cN; break;
case 'O': pLetter=cO; break;
case 'P': pLetter=cP; break;
case 'Q': pLetter=cQ; break;
case 'R': pLetter=cR; break;
case 'S': pLetter=cS; break;
case 'T': pLetter=cT; break;
case 'U': pLetter=cU; break;
case 'V': pLetter=cV; break;
case 'W': pLetter=cW; break;
case 'X': pLetter=cX; break;
case 'Y': pLetter=cY; break;
case 'Z': pLetter=cZ; break;
default:return;
}
//loop thru rows of the letter
for (int i=0; i<5; i++)
{
if (shift>0) //positive shift means letter is slid to the right on the display
v_grid[i] += (long)pLetter[i] << shift;
else //negative shift means letter is slid to the left so that only part of it is visible
v_grid[i] += (long)pLetter[i] >> -shift;
}
}
void scrollingText()
{
for (int i=0; i<strlen(text); i++)
{
drawLetter(text[i], i*5 + pixelPos);
}
pixelPos--;
if (pixelPos < -5*(int)strlen(text))
{
pixelPos=27;
scrollCount++;
}
showGrid();
}
void randomDisplay()
{
for (int device=0; device<3; device++)
for (int row=0; row<6; row++)
lc.setRow(device,row,random(0,256));
}