#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define PIN 3
#define STOPPIN 4
#define Brightness 255
#define COLS 64 // 
#define ROWS 8
#define NUM_LEDS COLS*ROWS
int i,k,z,l;
int j=0;
int skip =0;

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(COLS, ROWS, PIN,
  NEO_MATRIX_TOP     + NEO_MATRIX_LEFT +
  NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {matrix.Color(255, 0, 0),   matrix.Color(0, 255, 0),  matrix.Color(0, 0, 255), matrix.Color(255, 255, 0),   matrix.Color(0, 255, 255),  matrix.Color(255, 0, 255)   };
#define NoColor 3
String message = "";  // Type your Text Message here
int len =0;

//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
void setup() {
  Serial.begin(9600);
  pinMode(STOPPIN,INPUT);
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(Brightness);
  matrix.setTextColor(colors[0]);
  matrix.fillScreen(0);
  matrix.show();
  delay(1000);
  len = message.length();
}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

//////////////////////////////////
int x    = matrix.width();      //
int y    = matrix.height();     //
//////////////////////////////////

// ==============================================================================
void loop() 
{
  textmessage();
  
  if (skip ==1)
  {
Effect1(); Serial.println("Design 1 Completed");
  Effect2(); Serial.println("Design 2 Completed"); // triangle
  Effect3(); Serial.println("Design 3 Completed"); 
  Effect4(); Serial.println("Design 4 Completed");
  Effect5(); Serial.println("Design 5 Completed");
  Effect6(); Serial.println("Design 6 Completed");
  Effect7(); Serial.println("Design 7 Completed");
  Effect8(); Serial.println("Design 8 Completed"); 
  Effect9(); Serial.println("Design 9 Completed"); // heart
  Effect10(); Serial.println("Design 10 Completed"); // joining arrow
  Effect11(); Serial.println("Design 11 Completed"); 
  Effect12(); Serial.println("Design 12 Completed"); 
  Effect13(); Serial.println("Design 13 Completed"); 
  Effect14(); Serial.println("Design 14 Completed"); 
  Effect15(); Serial.println("Design 15 Completed"); 
  Effect16(); Serial.println("Design 16 Completed");
 
  skip=0;  j=0;  i=0; k=0;  z=0; l=0;
 }
}
// ==============================================================================

// ------------------------------------------------------------------------------
void textmessage()
{
  matrix.fillScreen(0);
  matrix.setCursor(x, 0);
  matrix.print(message);
  if (len==0)
  {
    skip=1;
    return;
  }
  if(--x < -len*6) {
    x = matrix.width();
    if(++j >= 3)    // 3 means no of colors scrolling text
    {
      j = 0;
      skip=1;
    }
    matrix.setTextColor(colors[j]);
  }
  matrix.show();
  delay(20);
}
// ------------------------------------------------------------------------------





// ===============================================================
void Effect14()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =30;
l=0;
 for(k=0;k<5; k++)      // K value is  no of time cycle repeating
{
  for(l=0;l<NoColor-1; l=l+2)
{
for (j=0; j<y; j++)
{
for (i=0; i<x; i=i+16)
{
matrix.drawLine(0+i,j,7+i,7-j,colors[l]);
matrix.drawLine(8+i,7-j,15+i,j,colors[l]);
}
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}

for (j=0; j<y; j++)
{
for (i=0; i<x; i=i+16)
{
matrix.drawLine(0+i,7-j,7+i,j,colors[l]);
matrix.drawLine(8+i,j,15+i,7-j,colors[l]);
}
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}
}
}
}
//========================================================


// ------------------------------------------------------------------------------
void Effect13()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =10;
l=0;
// return;
 for(k=0;k<2; k++)      // K value is  no of time cycle repeating
{
  for(l=0;l<NoColor-1; l=l+2)
{

for (i=0; i<x/4-3; i++)
{
matrix.fillScreen(0); 
matrix.fillRect(i,y-3,4,3,colors[l]);
matrix.fillRect(x-4-i,0,4,3,colors[l+1]);
matrix.show();
delay(delaytime);
}
for (i=0; i<y-2; i++)
{
matrix.fillScreen(0); 
matrix.fillRect(x/4-4+i,y-3-i,4,3,colors[l]);
matrix.fillRect(x/4*3-i,i,4,3,colors[l+1]);
matrix.show();
delay(delaytime);
}

for (i=0; i<x/2; i++)
{
matrix.fillScreen(0); 
matrix.fillRect(x/4+y-7+i,0,4,3,colors[l]);
matrix.fillRect(x/4*3-y+3-i,y-3,4,3,colors[l+1]);
matrix.show();
delay(delaytime);
}
}
}
}
// ------------------------------------------------------------------------------


//===============================================================================
void Effect12()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =10;
l=0;
// return;
 for(k=0;k<1; k++)      // K value is  no of time cycle repeating
{
  for(l=0;l<NoColor-1; l=l+2)
{
for (j=0; j<x+8; j=j+8)
{
for (i=0; i<y-4; i++)
{
matrix.fillCircle(2+i+j,y-3-i,2,colors[l]);
matrix.fillCircle(i+j-6,y-3-i,2,colors[l+1]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}

for (i=0; i<y-4; i++)
{
matrix.fillCircle(6+i+j,2+i,2,colors[l]);
matrix.fillCircle(i+j-2,2+i,2,colors[l+1]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}
}
}
}
}

//===============================================================================

//-------------------------------------------------------------------------------
void Effect11()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =1;
l=0;
// return;
 for(k=0;k<1; k++)      // K value is  no of time cycle repeating
{
  for(l=0;l<NoColor; l++)
{
for (j=0; j<y; j++)
{
for (i=0; i<x; i=i+8)
{
matrix.drawLine(i,0,i+7,7-j,colors[l]);
}
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}
for (j=0; j<y; j++)
{
for (i=0; i<x; i=i+8)
{
matrix.drawLine(i,j,i+7,0,colors[l]);
}
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}

for (j=0; j<y; j++)
{
for (i=0; i<x; i=i+8)
{
matrix.drawLine(i+j,7,i+7,0,colors[l]);
}
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}

for (j=0; j<y; j++)
{
for (i=0; i<x; i=i+8)
{
matrix.drawLine(i+7,7,i+7-j,0,colors[l]);
}
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}
}
}
}
//-------------------------------------------------------------------------------

//===============================================================================
void Effect10()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =30;
l=0;
// return;
 for(k=0;k<5; k++)      // K value is  no of time cycle repeating
{
for (i=0; i<x-6; i++)
{
matrix.fillRect(0+i,0,3,2,colors[l]);
matrix.fillRect(0+i,6,3,2,colors[l]);
matrix.fillRect(3+i,2,4,4,colors[l]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}


for (i=0; i<x-10; i++)
{
matrix.fillScreen(0); 
matrix.fillRect(0+i,0,3,2,colors[l+1]);
matrix.fillRect(0+i,6,3,2,colors[l+1]);
matrix.fillRect(3+i,2,4,4,colors[l+1]);

matrix.fillRect(x-7,0,3,2,colors[l]);
matrix.fillRect(x-7,6,3,2,colors[l]);
matrix.fillRect(x-4,2,4,4,colors[l]);

matrix.show();
delay(delaytime);
}

for (i=0; i<x-14; i++)
{
matrix.fillScreen(0); 
matrix.fillRect(0+i,0,3,2,colors[l+2]);
matrix.fillRect(0+i,6,3,2,colors[l+2]);
matrix.fillRect(3+i,2,4,4,colors[l+2]);

matrix.fillRect(x-11,0,3,2,colors[l+1]);
matrix.fillRect(x-11,6,3,2,colors[l+1]);
matrix.fillRect(x-8,2,4,4,colors[l+1]);

matrix.fillRect(x-7,0,3,2,colors[l]);
matrix.fillRect(x-7,6,3,2,colors[l]);
matrix.fillRect(x-4,2,4,4,colors[l]);

matrix.show();
delay(delaytime);
}
for (i=0; i<x-18; i++)
{
matrix.fillScreen(0); 

matrix.fillRect(x-15,0,3,2,colors[l+2]);
matrix.fillRect(x-15,6,3,2,colors[l+2]);
matrix.fillRect(x-12,2,4,4,colors[l+2]);

matrix.fillRect(x-11,0,3,2,colors[l+1]);
matrix.fillRect(x-11,6,3,2,colors[l+1]);
matrix.fillRect(x-8,2,4,4,colors[l+1]);

matrix.fillRect(x-7,0,3,2,colors[l]);
matrix.fillRect(x-7,6,3,2,colors[l]);
matrix.fillRect(x-4,2,4,4,colors[l]);

matrix.fillRect(0+i,0,3,2,colors[l+3]);
matrix.fillRect(0+i,6,3,2,colors[l+3]);
matrix.fillRect(3+i,2,4,4,colors[l+3]);

matrix.show();
delay(delaytime);
}
}
}
//===============================================================================

//-------------------------------------------------------------------------------
void Effect9()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =40;
l=0;
// return;
 for(k=0;k<1; k++)      // K value is  no of time cycle repeating
{
  for(l=0;l<NoColor; l++)
{
for (i=0; i<x-11; i++)
{
matrix.drawLine(x-1,2,x-1,4,colors[0]);  // Heart
matrix.drawLine(x-2,1,x-2,5,colors[0]);
matrix.drawLine(x-3,2,x-3,6,colors[0]);
matrix.drawLine(x-4,1,x-4,5,colors[0]);
matrix.drawLine(x-5,2,x-5,4,colors[0]);

matrix.fillRect(1,0,3,3,colors[l+1]);   // Man
matrix.drawLine(0,7,4,7,colors[l+1]);
matrix.drawLine(0,4,4,4,colors[l+1]);
matrix.drawLine(2,3,2,7,colors[l+1]);

matrix.drawLine(6+i,4,9+i,4,colors[l+1]);    // Arrow
matrix.drawLine(8+i,3,8+i,5,colors[l+1]);

matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
}
for (i=0; i<x-10; i++)
{
matrix.fillRect(1,0,3,3,colors[l+1]);   // Man
matrix.drawLine(0,7,4,7,colors[l+1]);
matrix.drawLine(0,4,4,4,colors[l+1]);
matrix.drawLine(2,3,2,7,colors[l+1]);

matrix.drawLine(x-1-i,2,x-1-i,4,colors[0]);  // Heart
matrix.drawLine(x-2-i,1,x-2-i,5,colors[0]);
matrix.drawLine(x-3-i,2,x-3-i,6,colors[0]);
matrix.drawLine(x-4-i,1,x-4-i,5,colors[0]);
matrix.drawLine(x-5-i,2,x-5-i,4,colors[0]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
}
}
}
}
//-------------------------------------------------------------------------------


//===============================================================================
void Effect8()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =20;
l=0;
// return;
 for(k=0;k<3; k++)      // K value is 3 means no of time cycle repeating
{
  for(l=0;l<NoColor-1; l++)
{
for (i=0; i<x/2-11; i++)
{
matrix.fillRect(4,0,4,3,colors[l]);
matrix.fillRect(x-8,0,4,3,colors[l+1]);
matrix.fillRect(8+i,y-3,4,3,colors[l]);
matrix.fillRect(x-12-i,y-3,4,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
}


for (i=y-3; i>=0; i--)
{
matrix.fillRect(4,0,4,3,colors[l]);
matrix.fillRect(x-8,0,4,3,colors[l+1]);
matrix.fillRect(x/2-4,i,4,3,colors[l]);
matrix.fillRect(x-x/2,i,4,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 

}


for (i=0; i<x/2-7; i++)
{
matrix.fillRect(4,0,4,3,colors[l]);
matrix.fillRect(x-8,0,4,3,colors[l+1]);
matrix.fillRect(x/2-4-i,0,4,3,colors[l]);
matrix.fillRect(x/2+i,0,4,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
}
for (i=0; i<5; i++)
{
matrix.fillRect(4-i,0,4,3,colors[l]);
matrix.fillRect(x-8+i,0,4,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 

}


for (i=0; i<y-2; i++)
{
matrix.fillRect(0,i,4,3,colors[l]);
matrix.fillRect(x-4+i,0,4,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
}

for (i=0; i<9; i++)
{
matrix.fillRect(i,y-3,4,3,colors[l]);
matrix.fillRect(x-4-i,y-3,4,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 

}
}
}
}
//===============================================================================



//-------------------------------------------------------------------------------
void Effect7()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =3;
l=0;
// return;
 for(k=0;k<1; k++)      // 3 value is 1 means no of time cycle repeating
{
  for(l=0;l<NoColor-1; l++)
{
 for(i=0; i<NUM_LEDS; i++)
{ 
  matrix.setPixelColor(i, colors[l]);
  matrix.setPixelColor(NUM_LEDS-i, colors[l+1]);
  matrix.show(); 
  delay(delaytime);
}
}
}
}

//-------------------------------------------------------------------------------

//===============================================================================
void Effect6()
{
matrix.fillScreen(0); 
matrix.show(); 
int delaytime =3;
l=0;
// return;
for(k=0;k<1; k++)      // K value is 1 means no of time cycle repeating
{
for(l=0;l<NoColor; l++)
{
 for(i=0;i<x; i++)
{ 
matrix.drawLine(0,0,i,0,colors[l]);   //Line 1
matrix.show(); 
delay(delaytime);
}

for(i=0;i<y; i++)
{ 
matrix.drawLine(x-1,0,x-1,i,colors[l]);  // Line 2
matrix.show(); 
delay(delaytime);
}
 for(i=x-1;i>=0; i--)
{ 
matrix.drawLine(x-1,y-1,i,y-1,colors[l]);  // Line 3
matrix.show(); 
delay(delaytime);
}

for(i=y-1;i>0; i--)
{ 
matrix.drawLine(0,y-1,0,i,colors[l]);  // Line 4
matrix.show(); 
delay(delaytime);
}

for(i=0; i<x-1; i++)
{ 
matrix.drawLine(1,1,i,1,colors[l]);  // Line 5
matrix.show(); 
delay(delaytime);

}

for(i=1;i<y-1; i++)
{ 
matrix.drawLine(x-2,1,x-2,i,colors[l]);  // Line 6
matrix.show(); 
delay(delaytime);
}

 for(i=x-2;i>=1; i--)
{ 
matrix.drawLine(x-2,y-2,i,y-2,colors[l]);   // Line 7
matrix.show(); 
delay(delaytime);
}

for(i=y-2;i>1; i--)
{ 
matrix.drawLine(1,y-1,1,i,colors[l]);    // Line 8
matrix.show(); 
delay(delaytime);
}



for(i=2; i<x-2; i++)
{ 
matrix.drawLine(2,2,i,2,colors[l]);  // Line 9
matrix.show(); 
delay(delaytime);

}

for(i=3;i<y-2; i++)
{ 
matrix.drawLine(x-3,2,x-3,i,colors[l]);  // Line 10
matrix.show(); 
delay(delaytime);
}


 for(i=x-3;i>=2; i--)
{ 
matrix.drawLine(x-3,y-3,i,y-3,colors[l]);   // Line 11
matrix.show(); 
delay(delaytime);
}


for(i=y-3;i>2; i--)
{ 
matrix.drawLine(2,y-2,2,i,colors[l]);    // Line 12
matrix.show(); 
delay(delaytime);
}

for(i=3; i<x-3; i++)
{ 
matrix.drawLine(3,3,i,3,colors[l]);  // Line 13
matrix.show(); 
delay(delaytime);

}

for(i=4;i<y-3; i++)
{ 
matrix.drawLine(x-4,3,x-4,i,colors[l]);  // Line 14
matrix.show(); 
delay(delaytime);
}
 for(i=x-4;i>=3; i--)
{ 
matrix.drawLine(x-4,y-4,i,y-4,colors[l]);   // Line 15
matrix.show(); 
delay(delaytime);
}
for(i=0;i<5; i++)
{
matrix.fillRect(0,0,x,y,colors[l]);
matrix.show(); 
delay(100);
matrix.fillScreen(0); 
matrix.show();
delay(100);
}
}
}
}
//===============================================================================



//-------------------------------------------------------------------------------
void Effect5()
{
matrix.fillScreen(0); 
matrix.show(); 
stopsignal();
int delaytime =1;
l=0;
// return;
for(k=0;k<2; k++)      // K value is  no of time cycle repeating
{
for(l=0;l<NoColor; l++)
{
 for(i=0;i<x; i++)
{ 
int m =y-i;
if (m<3) m=2;
matrix.fillRect(0,0,x-i,m,colors[l]);
matrix.show(); 
stopsignal();
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
stopsignal();
}

 for(i=0;i<x-6; i++)
{ 
matrix.fillRect(0,0,i,2,colors[l]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
stopsignal();
}
 for(i=0;i<6; i++)
{ 
matrix.fillRect(0,0,x-6+i,2+i,colors[l]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
stopsignal();
}
}
}
}

//-------------------------------------------------------------------------------


//===============================================================================
void Effect4()
{
matrix.fillScreen(0); 
matrix.show(); 
int delaytime =1;
l=0;
// return;
for(k=0;k<2; k++)      // K value is  no of time cycle repeating
{
for(l=0;l<NoColor-1; l++)
{
for(i=0;i<x; i++)
{  
matrix.fillTriangle(i,0,i,6, i+ 3,3,colors[l]);
matrix.fillTriangle(x-1-i,0,x-1-i,6,x-4-i,3, colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
stopsignal();
}
}
}
}
//===============================================================================

//-------------------------------------------------------------------------------
void Effect3()
{
matrix.fillScreen(0); 
matrix.show(); 
int delaytime =3;
l=0;
// return;
for(k=0;k<2; k++)      // K value is  no of time cycle repeating
{
for(l=0;l<NoColor-1; l++)
{
for(i=0;i<x/2-4; i++)
{
matrix.fillRect(i,0,5,3,colors[l]);
matrix.fillRect(x-5-i,y-3,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
}

for(j=0;j<y-2; j++)
{
matrix.fillRect(i-1,j,5,3,colors[l]);
matrix.fillRect(x-4-i,y-3-j,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();

}


for(i=x/2-6;i>=0; i--)
{
matrix.fillRect(i,y-3,5,3,colors[l]);
matrix.fillRect(x-5-i,0,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
}

for(j=0;j<y-2; j++)
{
matrix.fillRect(i+1,y-3-j,5,3,colors[l]);
matrix.fillRect(x-6-i,j,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
}
}  
}
}
//-------------------------------------------------------------------------------


//===============================================================================
void Effect1()
{
matrix.fillScreen(0); 
matrix.show(); 
int delaytime =3;
l=0;
// return;
for(k=0;k<2; k++)      // K value is 5 means no of time cycle repeating
{
for(l=0;l<NoColor-1; l++)
{
for(i=0;i<x/2-4; i++)
{
matrix.fillRect(i,0,5,3,colors[l]);
matrix.fillRect(x-5-i,y-3,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
}

for(j=0;j<y-2; j++)
{
matrix.fillRect(i-1,j,5,3,colors[l]);
matrix.fillRect(x-4-i,y-3-j,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
}


for(i=0;i<x/2; i++)
{
matrix.fillRect(x/2-5+i,y-3,5,3,colors[l]);
matrix.fillRect(x/2-i,0,5,3,colors[l+1]);
matrix.show(); 
delay(delaytime);
matrix.fillScreen(0); 
matrix.show();
}
}
}
}
//===============================================================================

//-------------------------------------------------------------------------------
void Effect2()
{
matrix.fillScreen(0);
matrix.show();
int delaytime =10;
// return;
for (j=0; j<NoColor; j++)
{
  for (i=0; i<x/2; i++)

{
matrix.fillTriangle(x/2-1,0,x/2-1,y-1,x/2-i,y/2,colors[j]);
matrix.fillTriangle(x/2-1,0,x/2-1,y-1,x/2+i,y/2,colors[j]);
matrix.show();
delay(delaytime);
}
for (i=0; i<x/2; i++)
{matrix.fillScreen(0);
matrix.show();
matrix.fillTriangle(x/2-1,0,x/2-1,y-1,x-i-1,y/2,colors[j]);
matrix.fillTriangle(x/2-1,0,x/2-1,y-1,i,y/2,colors[j]);
matrix.show();
delay(delaytime);
}
}
}
//-------------------------------------------------------------------------------




void Effect15()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =500;
l=0;
for(k=0;k<2; k++)      // K value is 5 means no of time cycle repeating
{
for(l=0;l<NoColor-1; l++)
{
for (i=0; i<x/2-6; i++)
{matrix.fillScreen(0);
matrix.fillRect(1+i,0,3,3,colors[l+1]);   // Man
matrix.drawLine(0+i,7,4+i,7,colors[l+1]);
matrix.drawLine(0+i,4,4+i,4,colors[l+1]);
matrix.drawLine(2+i,3,2+i,7,colors[l+1]);

matrix.fillRect(x-4-i,0,3,3,colors[l+1]);   // Woman
matrix.drawLine(x-1-i,7,x-5-i,7,colors[l+1]);
matrix.drawLine(x-1-i,4,x-5-i,4,colors[l+1]);
matrix.drawLine(x-3-i,3,x-3-i,7,colors[l+1]);
matrix.drawLine(x-2-i,6,x-4-i,6,colors[l+1]);


matrix.show();
delay(delaytime);
}

for (i=0; i<10; i++)
{
matrix.fillRect(x/2-7,0,3,3,colors[l+1]);   // Man
matrix.drawLine(x/2-8,7,x/2-4,7,colors[l+1]);
matrix.drawLine(x/2-8,4,x/2-4,4,colors[l+1]);
matrix.drawLine(x/2-6,3,x/2-6,7,colors[l+1]);

matrix.fillRect(x/2+3,0,3,3,colors[l+1]);   // Woman
matrix.drawLine(x/2+6,7,x/2+2,7,colors[l+1]);
matrix.drawLine(x/2+2,4,x/2+6,4,colors[l+1]);
matrix.drawLine(x/2+4,3,x/2+4,7,colors[l+1]);
matrix.drawLine(x/2+5,6,x/2+3,6,colors[l+1]);
j=i%2;
if (j==0)
{
matrix.drawLine(x/2+1,2,x/2+1,4,colors[0]);  // Heart
matrix.drawLine(x/2,1,x/2,5,colors[0]);
matrix.drawLine(x/2-1,2,x/2-1,6,colors[0]);
matrix.drawLine(x/2-2,1,x/2-2,5,colors[0]);
matrix.drawLine(x/2-3,2,x/2-3,4,colors[0]);
}
matrix.show();
delay(200);
matrix.fillScreen(0); 
}

}
}

}



void Effect16()
{
matrix.fillScreen(0); 
matrix.show();
int delaytime =1;
for(l=0;l<NoColor-1; l++)
{
  for (i=0; i<x-3; i++)

{
matrix.fillRect(i,0,4,3,colors[l]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}

for (i=0; i<y-2; i++)
{
matrix.fillRect(x-4,i,4,3,colors[l]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}
for (i=0; i<x-3; i++)
{
matrix.fillRect(x-4-i,y-3,4,3,colors[l]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}

for (i=0; i<y-2; i++)
{
matrix.fillRect(0,y-3-i,4,3,colors[l]);
matrix.show();
delay(delaytime);
matrix.fillScreen(0); 
}
}
}

void stopsignal()
{
  int stopstat= digitalRead(STOPPIN);
  if((stopstat))
  {
    matrix.fillScreen(0); 
    matrix.setCursor(5, 0);
    matrix.setTextColor(colors[0]);
    matrix.print("STOP");
    matrix.show();
    delay(500);
    while((stopstat))
    {stopstat= digitalRead(STOPPIN);}
    matrix.fillScreen(0); 
  }
}