Thông báo

Collapse
No announcement yet.

giúp giải thích code 89s52!

Collapse
X
 
  • Lọc
  • Giờ
  • Show
Clear All
new posts

  • #16
    cho cái code này ngâm cứu nhá...đừng sửa gì cả..chỉ sửa lại mã hiển thị thôi nhá...
    Code:
    #include<regx52.h>
    #include<intrins.h>
    #include<stdlib.h>
    sbit hang1=P1^0;
    sbit hang2=P1^1;
    sbit hang3=P1^2;
    sbit hang4=P1^3;
    sbit hang5=P1^4;
    sbit cot25=P1^5;
    int k;
    char kt=0;
    void delay(int x)
    {
    	int i;
    	for(i=0;i<=x;i++);
    }
    
    void bat_tat(void)
    {
    	int i;
    	unsigned int x=35000;
    	for(i=0;i<=50;i++)
    	{
    	hang1=hang2=hang3=hang4=hang5=0;
    	P0=P2=P3=0x00; cot25=0;delay(x);
    	P0=P2=P3=0xff;cot25=1;delay(x);
    	x=x-1000;
    	}
    }  
    void quay(void)
    {
    	char i;
    	hang2=hang3=hang4=0; hang1=hang5=1;
    	for(i=0;i<=10;i++)
    	{
    		P0=0xff; P2=0xC7; P3=0xff; cot25=1; delay(7000);
    		P0=0xff; P2=0xee; P3=0xfe; delay(7000);
    		P0=0x7f; P2=0xef; P3=0xfd; delay(7000);	
    		P0=0xbf; P2=0xef; P3=0xfb; delay(7000);		
    	}
    	hang1=hang5=0;
    	for(i=0;i<=10;i++)
    	{
    		P0=0xbe;P2=0xef;P3=0xfb;cot25=0;delay(7000);
    		cot25=1;P0=0xff;P2=0x83;P3=0xff;delay(7000);
    		P0=0xef;P2=0xee;P3=0xee;delay(7000);
    		P0=0x7b;P2=0xef;P3=0xbd;delay(7000);	
    	}
    	hang1=hang5=1;
    	for(i=0;i<=10;i++)
    	{
    		P0=0xff; P2=0xC7; P3=0xff; cot25=1; delay(7000);
    		P0=0xbf; P2=0xef; P3=0xfb; delay(7000);	
    		P0=0x7f; P2=0xef; P3=0xfd; delay(7000);
    		P0=0xff; P2=0xee; P3=0xfe; delay(7000);		
    	}
    	hang1=hang5=0;
    	for(i=0;i<=10;i++)
    	{
    		cot25=1;P0=0x7b;P2=0xef;P3=0xbd;delay(7000);
    		P0=0xef;P2=0xee;P3=0xee;delay(7000);
    		P0=0xff;P2=0x83;P3=0xff;delay(7000);
    		P0=0xbe;P2=0xef;P3=0xfb;cot25=0;delay(7000);	
    	}	
    }
    quay2(void)
    {	char i,j,k;
    	unsigned char code mang[10]={0xfe,0xfd,0xfB,0xf7,0xeF,0xeF,0xf7,0xfB,0xfd,0xfe};
    	for(k=0;k<=1;k++)
    	{
    	for(j=0;j<=4;j++)
    	{
    	P1=mang[j];
    	for(i=0;i<=5;i++)
    	{
    		P0=0xbe;P2=0xef;P3=0xfb;cot25=0;delay(7000);
    		cot25=1;P0=0xff;P2=0x83;P3=0xff;delay(7000);
    		P0=0xef;P2=0xee;P3=0xee;delay(7000);
    		P0=0x7b;P2=0xef;P3=0xbd;delay(7000);	
    	}
    	}
    	for(j=0;j<=4;j++)
    	{
    	P1=mang[j+5];
    	for(i=0;i<=5;i++)
    	{
    		cot25=1;P0=0x7b;P2=0xef;P3=0xbd;delay(7000);
    		P0=0xef;P2=0xee;P3=0xee;delay(7000);
    		P0=0xff;P2=0x83;P3=0xff;delay(7000);
    		P0=0xbe;P2=0xef;P3=0xfb;cot25=0;delay(7000);	
    	}	
    	}
    	}
    }
    void chay_mang(void)
    {
    	 const unsigned char mang[8]={0xDE,0xDD,0xDB,0xD7,0xCF,0xD7,0xDB,0xDD};
    	 const unsigned char mang2[5]={0xcE,0xd5,0xdB,0xd5,0xcE};
    	 unsigned char j;
    	 int i;
    	 for(i=0;i<=10;i++)
    	{
    		P0=P2=P3=0x00;cot25=0;
    		for(j=0;j<=4;j++)
    		{
    			P1=mang2[j];
    			delay(10000);
    		}
    	} 
    	for(i=0;i<=5;i++)
    	{
    		P0=P2=P3=0x00;
    		for(j=0;j<=7;j++)
    		{
    			P1=mang[j];
    			delay(10000);
    		}
    	} 
    	for(i=0;i<=10;i++) // mang dung vao ra
    	{
    		hang1=hang2=hang3=hang4=hang5=0;
    		P0=0xe0;P2=0xff;P3=0x0F; cot25=0;delay(10000);
    		P0=0x1F;P2=0x7c;P3=0xf0;cot25=1;delay(10000);
    		P0=0xff; P2=0x83;P3=0xff; delay(10000);
    		P0=0x1F;P2=0x7c;P3=0xf0;delay(10000);
    		P0=0xe0;P2=0xff;P3=0x0F; cot25=0;delay(10000);	
    	}
    	for(i=0;i<=5;i++)	
    	{	hang1=hang2=hang3=hang4=hang5=0;
    		P0=0xe0;P2=P3=0xff; cot25=1;delay(10000);
    		P0=0x1f; P2=0xfc; P3=0xff; cot25=1;	delay(10000);
    		P0=0xff; P2=0x83; delay(10000);
    		P2=0x7f; P3=0xf0;delay(10000);
    		P2=0xff; P3=0x0f; cot25=0;delay(10000);
    		cot25=1;P2=0x7f; P3=0xf0;delay(10000);
    		P2=0x83; P3=0xff;delay(10000);
    		P0=0x1f; P2=0xfc;delay(10000);
    	}
    	for(i=0;i<=10;i++) // mang dung trai phai
    	{
    		hang1=hang2=hang3=hang4=hang5=0;
    		P0=0xCE;P2=0x39;P3=0xE7;cot25=0;delay(10000);
    		P0=0xB5;P2=0xD6;P3=0x5A;cot25=1;delay(10000);
    		P0=0x7b; P2=0xEF;P3=0xBD;delay(10000);
    		P0=0xB5;P2=0xD6;P3=0x5A;delay(10000);
    		P0=0xCE;P2=0x39;P3=0xE7;cot25=0;delay(10000);cot25=1;
    	}
    	for(i=0;i<=5;i++)	
    	{
    		hang1=hang2=hang3=hang4=hang5=0;
    		P0=0xDE; P2=0x7b;P3=0xef;delay(10000);
    		P0=0xBD; P2=0xF7;P3=0xDE;delay(10000);
    		P0=0x7b; P2=0xEF;P3=0xBD;delay(10000);
    		P0=0xF7; P2=0xDE;P3=0x7B;delay(10000);
    		P0=0xEF; P2=0xBD;P3=0xF7; cot25=0;delay(10000);
    		P0=0xF7; P2=0xDE;P3=0x7B; cot25=1;delay(10000);
    		P0=0x7b; P2=0xEF;P3=0xBD;delay(10000);
    		P0=0xBD; P2=0xF7;P3=0xDE;delay(10000);	
    	}
    }
    void trai_tim(void)
    {
    	char l,j;
    	int i;
    	int k;
    	unsigned char code mang[5]={0xFE,0xFD,0xFB,0xF7,0xEF};
    	unsigned char code traitim[4][15]={{0xFF,0xFF,0xFF,0xFF,0xFF,  0xEF,0xD7,0xBB,0xAB,0xD7,  0xFF,0xFF,0xFF,0xFF,0xFF},
    									   {0xFF,0xFF,0xEF,0xEF,0xFF,  0xEF,0xFE,0xFF,0xEF,0xFE,  0xff,0xFE,0xEF,0xEF,0xFE},
    									   {0xff,0x7F,0xFB,0xFB,0x7F,  0xEF,0xFF,0xFF,0xEF,0xFF,  0xff,0xFD,0xBF,0xBF,0xFD},
        								   {0xff,0xBF,0xFE,0xFE,0xBF,  0xEF,0xFF,0xFF,0xEF,0xFF,  0xFF,0xFB,0xFF,0xFF,0xFB}};
    	for(i=0;i<=30;i++)
    	{	cot25=1;
    	for(l=0;l<=3;l++)
    	 {
    	  for(k=0;k<=10;k++)// vong lap tao tre
    	  {
    		for(j=0;j<=4;j++)
    		{	
    			P0=traitim[l][j];
    			P2=traitim[l][j+5];
    			P3=traitim[l][j+10];
    			P1=mang[j];
    		    if((j==2||j==3)&&l==3) cot25=0; 
    			delay(100);
    		}
    	
    	  }	
    	 }							
    	}
    } 
    void chu_so(void)
    {
    	char j,l;
    	int k;
    	unsigned char code mang[5]={0xFE,0xFD,0xFB,0xF7,0xEF};
    /////thay mã tên người iu ở đây :D
    	unsigned char code chuso[28][5]={
    							  {0xE0,0xEF,0xE0,0xEE,0xE0},			// 9
    							  {0xE0,0xEE,0xE0,0xEE,0xE0},	  		// 8
    							  {0xFb,0xFb,0xFb,0xF7,0xF0},			// 7
    							  {0xE0,0xEE,0xE0,0xFE,0xE0},			// 6
    							  {0xE0,0xEF,0xE0,0xFE,0xE0},			// 5
    							  {0xF7,0xF7,0xF0,0xF6,0xF6},  	     	// 4
    							  {0xF0,0xF7,0xF1,0xF7,0xF0},			// 3
    							  {0xE0,0xFE,0xE0,0xef,0xE0},			// 2
    							  {0xF1,0xFB,0xFB,0xF9,0xFB},			// 1
    							  {0xF1,0xEE,0xEE,0xEE,0xF1},			// O
    							  {0xFF,0xFF,0xFF,0xFF,0xFF},
    							  {0xF8,0xF6,0xF6,0xF6,0xF8}, 			// D
    							  {0xE0,0xFB,0xFB,0xFB,0xE0},			// I
    							  {0xF0,0xFE,0xF0,0xFE,0xF0},			// E
    							  {0xEE,0xE6,0xEA,0xEC,0xEE}, 			// N
    							  {0xFF,0xFF,0xFF,0xFF,0xFF},
    							  {0xFB,0xFB,0xFB,0xFB,0xE0},  	        // T
    							  {0xF1,0xEE,0xEE,0xEE,0xEE},			// U
    							  {0xF7,0xF7,0xF0,0xF6,0xF6},  	     	// 4
    							  {0xF6,0xFA,0xFC,0xFA,0xF6}, 			// K
    							  {0xF0,0xF7,0xF1,0xF7,0xF0},			// 3
    							  {0xFF,0xFF,0xFF,0xFF,0xFF},
    							  {0xEE,0xEE,0xE0,0xEE,0xEE}, 			// H
    							  {0xEE,0xEE,0xE0,0xF5,0xFB}, 	    	// A
    							  {0xF1,0xEE,0xEE,0xEE,0xEE},			// U
    							  {0xE0,0xFB,0xFB,0xFB,0xE0},			// I
    							  {0xFF,0xFF,0xFF,0xFF,0xFF},
    							  {0xFB,0xF5,0xEE,0xEA,0xF5}};	
    		cot25=1;
    		P2=P3=0xff;
    	for(l=0;l<=27;l++)	  // l= so mang
    	 {
    	  for(k=0;k<=120;k++)// vong lap tao tre
    	  {
    		for(j=0;j<=4;j++)
    		{	
    			P0=chuso[l][j];
    			P1=mang[j];
    			delay(100);
    		}
    	
    	  }	
    	 }							
    }
    /*void chuso2(void)
    {	//--------ma hex 8x8, tich cuc muc 0 va	D0-D7, quet theo cot-------------
    char j,i;
    int k,n;
    unsigned char code chu[134]={0xff,0xff,0xff,0xff,0xff, 
    0xE0,0xFD,0xFB,0xFD,0xE0,0xff, 		// W
    0xE0,0xEA,0xEA,0xEE,0xff,	   		// E
    0xE0,0xFE,0xFE,0xFF,				// L
    0xF1,0xEE,0xEE,0xEE,0xFF,			// C
    0xF1,0xEE,0xEE,0xEE,0xF1,0xff,   	// O
    0xE0,0xF7,0xFB,0xF7,0xE0,0xff,		// M
    0xE0,0xEA,0xEA,0xEE,0xff,0xff,	    // E
    0xE0,0xEE,0xEE,0xF1,0xff, 			// D
    0xF8,0xF3,0xEB,0xF3,0xF8,0xff, 		// A
    0xEE,0xE0,0xEE,0xFF,0xff,  			// I
    0xE0,0xFB,0xFB,0xE0,0xff,     		// H
    0xF1,0xEE,0xEE,0xEE,0xF1,0xff,   	// O
    0xF1,0xEE,0xEE,0xEE,0xFF,0xff,		// C
    0xE0,0xEE,0xEE,0xF1,0xff, 			// D
    0xEE,0xE0,0xEE,0xFF,  				// I
    0xE0,0xEA,0xEA,0xEE,0xff,	   		// E
    0xE0,0xF7,0xFB,0xFD,0xE0,0xFF,0xff, // N
    0xEF,0xEF,0xE0,0xEF,0xEF,0xff,  	// T
    0xE1,0xFE,0xFE,0xFE,0xE1,0xff,0xff, // U
    0xE3,0xFB,0xFB,0xE0,0xFF,  			// 4
    0xFB,0xFB,0xFB,0xff,				// -
    0xE0,0xFB,0xF5,0xEE,0xff,  			// K
    0xEE,0xEA,0xEA,0xE0,0xff,			// 3
    0xff,0xff,0xff,0xff,0xff};   
    		k=0; P0=P2=P3=0xff;
    		for(n=0;n<=129;++n) // n<= k-1
    		{
    			for(j=0;j<=20;j++)	// vong lap tao tre 
    			{	P0 = 0xfe;
    				for(i=0;i<=4;++i)	// vong lap quet led 
    				{
    					P1 = chu[i+k];
    					delay(200);
    					P0 = _crol_(P0,1);
    				}
    			}
    			// k= gia tri cua mang -5
    		k++; // quay chu theo chieu tu trai qua phai (neu k=0 va k++ thi quay phai qua trai)
    		}			
    }	*/	
    void locxoay(void)
    {
    	char i,j,n,k;
    	unsigned char code locxoay2[8][20]={{0xdE,0xfd,0xFB,0xF7,0xEF,  0xfE,0xfD,0xFB,0xF7,0xEF,  0xFF,0xFf,0xfF,0xFF,0xff,  0xff,0x7f,0xBf,0xDF,0xEF},
    								 {0xfE,0xfd,0xFB,0xf7,0xEF,  0xFD,0xFB,0xF7,0xEF,0xff,  0xff,0xff,0xff,0xff,0x7D,  0x7F,0xBF,0xDF,0xEF,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xFB,0xF7,0xef,0xff,0xff,  0xfF,0xff,0xff,0x7d,0xbb,  0xBf,0xdf,0xef,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xF7,0xef,0xff,0xff,0xdf,  0xff,0xff,0x7d,0xbB,0xff,  0xDF,0xEF,0xff,0xfF,0xf7},
    								 {0xfE,0xfd,0xfB,0xf7,0xCF,  0xEF,0xFf,0xff,0xDf,0xfE,  0xff,0x7d,0xbb,0xFf,0xff,  0xEF,0xff,0xff,0xf7,0xff},
    								 {0xfE,0xfd,0xfB,0xd7,0xEF,  0xff,0xff,0xdf,0xfe,0xfD,  0x7d,0xbb,0xFF,0xFf,0xfF,  0xff,0xFf,0xf7,0xff,0x7f},
    								 {0xfE,0xfd,0xdB,0xf7,0xEF,  0xff,0xdf,0xfe,0xfd,0xfB,  0xBB,0xff,0xff,0xff,0xfF,  0xff,0xf7,0xff,0x7f,0xBf},
    								 {0xfE,0xdd,0xfB,0xf7,0xEF,  0xdf,0xfe,0xfd,0xfB,0xF7,  0xFF,0xFf,0xfF,0xFF,0xff,  0xf7,0xfF,0x7f,0xBf,0xdf},	
    								 };
    	P1=0xff;
    	for(k=0;k<=15;k++)
    	{
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=6;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=locxoay2[j][i]; P0=locxoay2[j][i+5];P2=locxoay2[j][i+10]; 
    				P3=locxoay2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }
    void locxoay2(void)
    {
    	char i,j,n,k;
    	unsigned char code locxoay2[8][20]={{0xdE,0xfd,0xFB,0xF7,0xEF,  0xfE,0xfD,0xFB,0xF7,0xEF,  0xFF,0xFf,0xfF,0xFF,0xff,  0xff,0x7f,0xBf,0xDF,0xEF},
    								 {0xfE,0xdd,0xfB,0xf7,0xEF,  0xdf,0xfe,0xfd,0xfB,0xF7,  0xFF,0xFf,0xfF,0xFF,0xff,  0xf7,0xfF,0x7f,0xBf,0xdf},
    								 {0xfE,0xfd,0xdB,0xf7,0xEF,  0xff,0xdf,0xfe,0xfd,0xfB,  0xBB,0xff,0xff,0xff,0xfF,  0xff,0xf7,0xff,0x7f,0xBf},
    								 {0xfE,0xfd,0xfB,0xd7,0xEF,  0xff,0xff,0xdf,0xfe,0xfD,  0x7d,0xbb,0xFF,0xFf,0xfF,  0xff,0xFf,0xf7,0xff,0x7f},
    								 {0xfE,0xfd,0xfB,0xf7,0xCF,  0xEF,0xFf,0xff,0xDf,0xfE,  0xff,0x7d,0xbb,0xFf,0xff,  0xEF,0xff,0xff,0xf7,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xF7,0xef,0xff,0xff,0xdf,  0xff,0xff,0x7d,0xbB,0xff,  0xDF,0xEF,0xff,0xfF,0xf7},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xFB,0xF7,0xef,0xff,0xff,  0xfF,0xff,0xff,0x7d,0xbb,  0xBf,0xdf,0xef,0xff,0xff},
    								 {0xfE,0xfd,0xFB,0xf7,0xEF,  0xFD,0xFB,0xF7,0xEF,0xff,  0xff,0xff,0xff,0xff,0x7D,  0x7F,0xBF,0xDF,0xEF,0xff},
    								 };
    	P1=0xff;
    	for(k=0;k<=15;k++)
    	{
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=6;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=locxoay2[j][i]; P0=locxoay2[j][i+5];P2=locxoay2[j][i+10]; 
    				P3=locxoay2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  	 
    void song_ngang(void)
    {
    	char i,j,n,k;
    	unsigned char code mangsong[8][20]={{0xfE,0xfd,0xFB,0xF7,0xCF,  0xDE,0xBD,0x7B,0xF7,0xEF,  0x7B,0xF7,0xEF,0xDE,0xBD,  0xEF,0xDE,0xBD,0x7B,0xF7},
    								 {0xfE,0xfd,0xFB,0xD7,0xEF,  0xBD,0x5A,0xF7,0xEF,0xff,  0xF7,0x6B,0xDE,0xBD,0xff,  0xDE,0xAD,0x7B,0xF7,0xff},
    								 {0xfE,0xfd,0xdB,0xf7,0xEF,  0x7B,0xB5,0xCE,0xff,0xff,  0xEF,0xD6,0x39,0xff,0xff,  0xBD,0x5A,0xe7,0xff,0xff},
    								 {0xfE,0xdd,0xfB,0xf7,0xEF,  0xF7,0x6B,0xBD,0xDE,0xff,  0xDE,0xAD,0xF7,0x7B,0xff,  0x7B,0xB5,0xDE,0xEF,0xff},
    								 {0xdE,0xfd,0xfB,0xf7,0xEF,  0xEF,0xF7,0x7B,0xBD,0xDE,  0xBD,0xDE,0xEF,0xF7,0x7B,  0xF7,0x7B,0xBD,0xDE,0xEF},
    								 {0xfE,0xdd,0xfB,0xf7,0xEF,  0xff,0xEF,0xF7,0x5A,0xBD,  0xff,0xBD,0xDE,0x6B,0xF7,  0xff,0xF7,0x7B,0xAD,0xDE},
    								 {0xfE,0xfd,0xdB,0xf7,0xEF,  0xff,0xff,0xCE,0xB5,0x7B,  0xff,0xff,0x39,0xD6,0xEF,  0xff,0xff,0x39,0x5A,0xBD},
    								 {0xfE,0xfd,0xfB,0xd7,0xEF,  0xff,0xDE,0xBD,0x6B,0xF7,  0xff,0x7B,0xF7,0xAD,0xDE,  0xff,0xEF,0xDE,0xB5,0x7B},	
    								 };
    	P1=0xff;
    	for(k=0;k<=20;k++)
    	{
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=10;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mangsong[j][i]; P0=mangsong[j][i+5];P2=mangsong[j][i+10]; 
    				P3=mangsong[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  	  
    void song_ngang2(void)
    {
    	char i,j,n,k;
    	unsigned char code mangsong2[8][20]={{0xfE,0xfd,0xFB,0xF7,0xCF,  0xE0,0x1F,0xff,0xff,0xff,  0xff,0xFC,0x83,0x7F,0xff,  0xff,0xff,0xff,0xF0,0x0F },
    								 {0xfE,0xfd,0xFB,0xD7,0xEF,  0x1F,0xE0,0xff,0xff,0xff,  0xFC,0x83,0x7F,0xff,0xff,  0xff,0xff,0xF0,0x0F,0xff},
    								 {0xfE,0xfd,0xdB,0xf7,0xEF,  0xff,0x1F,0xE0,0xff,0xff,  0x83,0x7C,0xff,0xFF,0xFF,  0xff,0xF0,0x0F,0xFF,0xFF},
    								 {0xfE,0xdd,0xfB,0xf7,0xEF,  0xff,0xff,0x1F,0xE0,0xFF,  0x7F,0x83,0xFC,0xff,0xFF,  0xF0,0x0F,0xff,0xff,0xFF},
    								 {0xdE,0xfd,0xfB,0xf7,0xEF,  0xff,0xff,0xff,0x1F,0xE0,  0xff,0x7F,0x83,0xFC,0xff,  0x0F,0xF0,0xff,0xff,0xff},
    								 {0xfE,0xdd,0xfB,0xf7,0xEF,  0xff,0xFF,0xFF,0xE0,0x1F,  0xFF,0xFF,0x0F,0x83,0xFC,  0xFF,0x0F,0xF0,0xff,0xff},
    								 {0xfE,0xfd,0xdB,0xf7,0xEF,  0xFF,0xFF,0xE0,0x1F,0xff,  0xFF,0xFF,0xff,0x7C,0x83,  0xFF,0xFF,0x0F,0xF0,0xff},
    								 {0xfE,0xfd,0xfB,0xd7,0xEF,  0xFF,0xE0,0x1F,0xff,0xF7,  0xFF,0xff,0xFC,0x83,0x7F,  0xFF,0xff,0xff,0x0F,0xF0},	
    								 };
    	P1=0xff;
    	for(k=0;k<=20;k++)
    	{
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=10;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mangsong2[j][i]; P0=mangsong2[j][i+5];P2=mangsong2[j][i+10]; 
    				P3=mangsong2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	 
    /*void toatat(void)
    {
    	char i,j,n,k;
    	unsigned char code mang[6][20]={{0xfE,0xfd,0xFB,0xF7,0xfF,  0xFF,0xFF,0xFF,0xFF,0xFF,  0xFF,0xFF,0xEF,0xFF,0xFF,  0xFF,0xFF,0xFF,0xFF,0xFF},
    								 {0xff,0xfd,0xFB,0xf7,0xfF,  0xff,0x3F,0x3F,0x3F,0xff,  0xFf,0xC6,0xC6,0xC6,0xff,  0xDf,0xF8,0xF8,0xF8,0xff},
    								 {0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00},
    								 {0xDE,0xDD,0xDB,0xD7,0xCF,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x10,0x00,0x00,  0x00,0x00,0x00,0x00,0x00},
    								 {0xDE,0xDD,0xDB,0xD7,0xCF,  0x00,0xC0,0xC0,0xC0,0x00,  0x00,0x39,0x39,0x39,0x00,  0x00,0x07,0x07,0x07,0x00},
    								 {0xff,0xff,0xff,0xff,0xfF,  0xff,0xEF,0xF7,0x5A,0xBD,  0xff,0xBD,0xDE,0x6B,0xF7,  0xff,0xF7,0x7B,0xAD,0xDE}	
    								 };
    	P1=0xff;
    	for(k=0;k<=15;k++)
    	{
    	for(j=0;j<=5;j++)
    	{
    		for(n=0;n<=15;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang[j][i]; P0=mang[j][i+5];P2=mang[j][i+10]; 
    				P3=mang[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }*/	  	   	  
    void mua(void)
    {
    	char i,j,k;
    	unsigned char code mang[5]={0xFE,0xFC,0xF8,0xF0,0xE0};
    	unsigned char code mang1[5]={0xef,0xe7,0xE3,0xE1,0xE0};
    	unsigned char code mua[4][15]={{0xFE,0x9C,0x18,0x10,0x00,  0xff,0xff,0xE3,0x42,0x00,  0xff,0xFF,0xFF,0xf8,0x00},
    							  {0xEF,0xE7,0x63,0x21,0x00,  0xff,0xFC,0x8C,0x84,0x00,  0xff,0xFF,0xFF,0xF0,0x00},
    							  {0xff,0xff,0xFF,0x3F,0x00,  0xff,0xFF,0x8f,0x84,0x00,  0xff,0x73,0x31,0x10,0x00},
        						  {0xff,0xFF,0xFF,0x1F,0x00,  0xFF,0x7F,0x63,0x42,0x00,  0xEF,0xCE,0x8C,0x08,0x00}};
    	for(i=0;i<=2;i++)
    	{	cot25=1;
    	  for(k=0;k<=3;k++)
    	  {
    		for(j=0;j<=4;j++)
    		{	
    			P0=mua[k][j];
    			P2=mua[k][j+5];
    			P3=mua[k][j+10];
    			P1=mang[j];
    			if((k!=2)&&(j==4)||(k==2)) cot25=0; else cot25=1;
    			delay(12000);
    		}
    			for(j=0;j<=4;j++)
    		{	
    			P0=mua[k][j];
    			P2=mua[k][j+5];
    			P3=mua[k][j+10];
    			P1=mang1[j];
    			if((k!=2)&&(j==4)||(k==2)) cot25=0; else cot25=1;
    			delay(12000);
    		}
    	  }	
    								
    	}
    }  
    void sao(void)
    {
    	char i,j,n,k;
    	unsigned char code mang2[9][20]={{0xfE,0xfd,0xdB,0xd7,0xeF,  0x0f,0xfd,0xf3,0xf1,0xd3,  0xd3,0x4d,0x56,0xa8,0x57,  0x07,0x80,0x09,0x0f,0xa0},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0x7a,0x56,0xb2,0xb5,0x01,  0xb5,0x01,0x02,0x03,0x04,  0xcc,0x99,0xdd,0xef,0xa7},
    								 {0xaa,0x66,0xbb,0x77,0xfb,  0x6c,0x8f,0x1c,0xac,0xca,  0xEF,0xD7,0xBB,0xAB,0xD7,  0x7a,0x56,0xb2,0xb5,0x01},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xca,0xa2,0x59,0x19,0x48,  0x88,0xcc,0x99,0xdd,0xef,  0x57,0x12,0xfe,0x34,0xdf},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0x66,0xbb,0x77,0xfb,0x88,  0x6c,0x8f,0x1c,0xac,0xca,  0x55,0xaa,0x66,0xbb,0x77},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xcc,0x99,0xdd,0xef,0xa7,  0x56,0xa8,0x57,0x12,0xfe,  0xfb,0x88,0xcc,0x99,0xdd},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0x1c,0xac,0xca,0xa2,0x59,  0x56,0xb2,0xb5,0x01,0x02,  0xb5,0x01,0x02,0x03,0x04},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xcd,0x6c,0x8f,0x1c,0xac,  0x03,0x04,0x50,0x60,0x07,  0x8f,0x1c,0xac,0xca,0xa2},
    								 {0xfE,0xfd,0xdB,0xd7,0xeF,  0x77,0xfb,0x88,0xcc,0x99,  0x8f,0x1c,0xac,0xca,0xa2,  0xfb,0x88,0xcc,0x99,0xdd},	
    								 };
    	for(k=0;k<=5;k++)
    	{
    	P1=0xff;
    	for(j=0;j<=8;j++)
    	{
    		for(n=0;n<=30;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang2[j][i]; P0=mang2[j][i+5];P2=mang2[j][i+10]; 
    				P3=mang2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  
    void phao_hoa(void)
    {	char i;
    for(i=0;i<=4;i++)
    {
    	P0=0xff;P2=0xef;P3=0xff;cot25=1;
    	hang1=0;delay(5000);
    	hang1=1;hang2=0;delay(5000);
    	hang2=1;hang3=0;delay(5000);
    	hang3=1;hang4=0;delay(10000);
    	P0=0x3F;P2=0xC6;P3=0xF8;
    	hang5=0;hang3=0;delay(20000);
    	P0=0x00;P2=0x00;P3=0x00; cot25=0;
    	hang2=0;hang1=0;delay(20000);
    	hang1=hang2=hang3=hang4=hang5=1;		 
    }
    } 
    void sang_toa(void)
    {
    	char i;
    	int x=20000;
    	for(i=0;i<=25;i++)
    	{	cot25=1;
    		hang3=0;hang1=hang2=hang4=hang5=1;
    		P0=0xff;P2=0xEF;P3=0xff;delay(x);
    		P0=0x3F;P2=0xC6;P3=0xF8;
    		hang3=hang4=hang2=0;delay(x);
    		P0=0x00;P2=0x00;P3=0x00; cot25=0;
    		hang1=hang5=0;delay(x);
    		P0=0x3F;P2=0xC6;P3=0xF8;
    		hang1=hang5=1; cot25=1;delay(x);
    		hang3=0;hang1=hang2=hang4=hang5=1;
    		P0=0xff;P2=0xEF;P3=0xff;delay(x);
    		P2=0xff;delay(x);
    		x=x-1000;
    	}
    } 
    void song(void)
    {	char i;
    	for(i=0;i<=10;i++)
    	{	hang1=hang2=hang3=hang4=hang5=0;
    		P0=0xEF;P2=P3=0xEE; cot25=1;
    		delay(10000);
    		P0=0x77; P2=0x75; P3=0xff; cot25=1;
    		delay(10000);
    		P0=0xBB; P2=0xBA; 
    		delay(10000);
    		P0=0x5D; P2=0xDF; P3=0xF7;
    		delay(10000);
    		P0=0xBE; P2=0xEF; P3=0xFB; cot25=0;
    		delay(10000);
    		cot25=1;
    		P0=0xDF; P2=0xF7; P3=0x75;
    		delay(10000);
    	 	P0=0xff; P2=0xBB; P3=0xBA;
    		delay(10000);
    		P0=0xff; P2=0x5D; P3=0xDD; 
    		delay(10000);
    	} 
    } 
    void sau(void)
    {
    	char i;
    	for(i=0;i<=2;i++)
    	{
    	P1=0xff;
    	hang1=0;//hang1 sang
    	P0=0xfe;delay(5000);P0=0xfc;delay(5000);P0=0xf8;delay(5000);P0=0xf0;delay(5000);P0=0xe0;delay(5000);
    	P0=0xe1;delay(5000);P0=0xe3;delay(5000);P0=0xe7;delay(5000);P0=0xef;delay(5000);
    
    	P0=0xef;delay(5000);P2=0xfe;delay(5000);P2=0xee;delay(5000);P3=0xfe;delay(5000);P3=0xee;delay(5000);
    	P0=0xff;delay(5000);P2=0xef;delay(5000);P2=0xff;delay(5000);P3=0xef;delay(5000);
    
    	P3=0xef;delay(5000);P3=0xcf;delay(5000);P3=0x8f;delay(5000);P3=0x0f;delay(5000);cot25=0;delay(5000);
    	P3=0x1f;delay(5000);P3=0x3f;delay(5000);P3=0x7f;delay(5000);P3=0xff;delay(5000);
    
    	P3=0xfb;delay(5000);P2=0xef;delay(5000);P0=0xbf;delay(5000);P0=0xbe;delay(5000);
    	cot25=1;delay(5000);P3=0xff;delay(5000);P2=0xff;delay(5000);P0=0xfe;delay(5000);
    
    	P0=0xfe;delay(5000);hang2=0;delay(5000);hang3=0;delay(5000);hang4=0;delay(5000);hang5=0;delay(5000);
    	hang1=1;delay(5000);hang2=1;delay(5000);hang3=1;delay(5000);hang4=1;delay(5000);
    				  // hang5 sang
    	P0=0xfe;delay(5000);P0=0xfc;delay(5000);P0=0xf8;delay(5000);P0=0xf0;delay(5000);P0=0xe0;delay(5000);
    	P0=0xe1;delay(5000);P0=0xe3;delay(5000);P0=0xe7;delay(5000);P0=0xef;delay(5000);
    
    	P0=0xef;delay(5000);P2=0xfe;delay(5000);P2=0xee;delay(5000);P3=0xfe;delay(5000);P3=0xee;delay(5000);
    	P0=0xff;delay(5000);P2=0xef;delay(5000);P2=0xff;delay(5000);P3=0xef;delay(5000);
    
    	P3=0xef;delay(5000);P3=0xcf;delay(5000);P3=0x8f;delay(5000);P3=0x0f;delay(5000);cot25=0;delay(5000);
    	P3=0x1f;delay(5000);P3=0x3f;delay(5000);P3=0x7f;delay(5000);P3=0xff;delay(5000);
    
    	P3=0xff;delay(5000);P3=0xfb;delay(5000);P2=0xef;delay(5000);P0=0xbf;delay(5000);P0=0xbe;delay(5000);
    	cot25=1;delay(5000);P3=0xff;delay(5000);P2=0xff;delay(5000);P0=0xfe;delay(5000);
    	
    	hang4=0;delay(5000);hang3=0;delay(5000);hang5=1;delay(5000);hang4=1;delay(5000);
    	//        hang3 sang
    	P0=0xfe;delay(5000);P0=0xfc;delay(5000);P0=0xf8;delay(5000);P0=0xf0;delay(5000);P0=0xe0;delay(5000);
    	P0=0xe1;delay(5000);P0=0xe3;delay(5000);P0=0xe7;delay(5000);P0=0xef;delay(5000);
    
    	P0=0xef;delay(5000);P2=0xfe;delay(5000);P2=0xee;delay(5000);P3=0xfe;delay(5000);P3=0xee;delay(5000);
    	P0=0xff;delay(5000);P2=0xef;delay(5000);P2=0xff;delay(5000);P3=0xef;delay(5000);
    
    	P3=0xef;delay(5000);P3=0xcf;delay(5000);P3=0x8f;delay(5000);P3=0x0f;delay(5000);cot25=0;delay(5000);
    	P3=0x1f;delay(5000);P3=0x3f;delay(5000);P3=0x7f;delay(5000);P3=0xff;delay(5000);
    
    	P3=0xff;delay(5000);P3=0xfb;delay(5000);P2=0xef;delay(5000);P0=0xbf;delay(5000);P0=0xbe;delay(5000);
    	cot25=1;delay(5000);P3=0xff;delay(5000);P2=0xff;delay(5000);P0=0xfe;delay(5000);
    
    	hang4=0;delay(5000);hang3=1;delay(5000);
    	// hang4 sang
    	P0=0xfe;delay(5000);P0=0xfc;delay(5000);P0=0xf8;delay(5000);P0=0xf0;delay(5000);P0=0xe0;delay(5000);
    	P0=0xe1;delay(5000);P0=0xe3;delay(5000);P0=0xe7;delay(5000);P0=0xef;delay(5000);
    
    	P0=0xef;delay(5000);P2=0xfe;delay(5000);P2=0xee;delay(5000);P3=0xfe;delay(5000);P3=0xee;delay(5000);
    	P0=0xff;delay(5000);P2=0xef;delay(5000);P2=0xff;delay(5000);P3=0xef;delay(5000);
    
    	P3=0xef;delay(5000);P3=0xcf;delay(5000);P3=0x8f;delay(5000);P3=0x0f;delay(5000);cot25=0;delay(5000);
    	P3=0x1f;delay(5000);P3=0x3f;delay(5000);P3=0x7f;delay(5000);P3=0xff;delay(5000);
    
    	P3=0xff;delay(5000);P3=0xfb;delay(5000);P2=0xef;delay(5000);P0=0xbf;delay(5000);P0=0xbe;delay(5000);
    	cot25=1;delay(5000);P3=0xff;delay(5000);P2=0xff;delay(5000);P0=0xfe;delay(5000);
    
    	hang3=0;delay(5000);hang2=0;delay(5000);hang4=1;delay(5000);hang3=1;delay(5000);
    	//     hang2 sang
    	P0=0xfe;delay(5000);P0=0xfc;delay(5000);P0=0xf8;delay(5000);P0=0xf0;delay(5000);P0=0xe0;delay(5000);
    	P0=0xe1;delay(5000);P0=0xe3;delay(5000);P0=0xe7;delay(5000);P0=0xef;delay(5000);
    
    	P0=0xef;delay(5000);P2=0xfe;delay(5000);P2=0xee;delay(5000);P3=0xfe;delay(5000);P3=0xee;delay(5000);
    	P0=0xff;delay(5000);P2=0xef;delay(5000);P2=0xff;delay(5000);P3=0xef;delay(5000);
    
    	P3=0xef;delay(5000);P3=0xcf;delay(5000);P3=0x8f;delay(5000);P3=0x0f;delay(5000);cot25=0;delay(5000);
    	P3=0x1f;delay(5000);P3=0x3f;delay(5000);P3=0x7f;delay(5000);P3=0xff;delay(5000);
    
    	P3=0xff;delay(5000);P3=0xfb;delay(5000);P2=0xef;delay(5000);P0=0xbf;delay(5000);P0=0xbe;delay(5000);
    	cot25=1;delay(5000);P3=0xff;delay(5000);P2=0xff;delay(5000);P0=0xfe;delay(5000);
    	}
    }
    void quay_ngang(void)
    {
    	char i,j,n,k;
    	unsigned char code mang[4][20]={{0xfE,0xfd,0xFB,0xF7,0xCF,  0xE0,0x1F,0xFF,0xFF,0xFF,  0xFF,0xFC,0x83,0x7F,0xff,  0xFF,0xFF,0xFF,0xF0,0x0F},
    								 {0xff,0xff,0xdB,0xff,0xfF,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00},
    								 {0xdE,0xfd,0xfB,0xf7,0xEF,  0xff,0xff,0xff,0x1F,0xE0,  0xff,0x7F,0x83,0xFC,0xff,  0x0F,0xF0,0xff,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xFF,0xFF,0xFF,0xFF,0xFF,  0x83,0x83,0x83,0x83,0x83,  0xFF,0xFF,0xFF,0xFF,0xFF},	
    								 };
    	P1=0xff;
    	for(k=0;k<=10;k++)
    	{
    	for(j=0;j<=3;j++)
    	{
    		for(n=0;n<=6;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang[j][i]; P0=mang[j][i+5];P2=mang[j][i+10]; 
    				P3=mang[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  	 
    void quay_ngang2(void)
    {
    	char i,j,n,k;
    	unsigned char code mang[4][20]={{0xfE,0xfd,0xFB,0xF7,0xCF,  0xE0,0x1F,0xFF,0xFF,0xFF,  0xFF,0xFC,0x83,0x7F,0xff,  0xFF,0xFF,0xFF,0xF0,0x0F},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xFF,0xFF,0xFF,0xFF,0xFF,  0x83,0x83,0x83,0x83,0x83,  0xFF,0xFF,0xFF,0xFF,0xFF},
    								 {0xdE,0xfd,0xfB,0xf7,0xEF,  0xff,0xff,0xff,0x1F,0xE0,  0xff,0x7F,0x83,0xFC,0xff,  0x0F,0xF0,0xff,0xff,0xff},
    								 {0xff,0xff,0xdB,0xff,0xfF,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00},	
    								 };
    	P1=0xff;
    	for(k=0;k<=10;k++)
    	{
    	for(j=0;j<=3;j++)
    	{
    		for(n=0;n<=6;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang[j][i]; P0=mang[j][i+5];P2=mang[j][i+10]; 
    				P3=mang[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  	 
    void quay_ngang3(void)
    {
    	char i,j,n,k;
    	unsigned char code mang[4][20]={{0xfE,0xfd,0xFB,0xF7,0xCF,  0xDE,0xBD,0x7B,0xF7,0xEF,  0x7B,0xF7,0xEF,0xDE,0xBD,  0xEF,0xDE,0xBD,0xF0,0x7B},
    								 {0xff,0xff,0xdB,0xff,0xfF,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00},
    								 {0xdE,0xfd,0xFB,0xF7,0xeF,  0xEF,0xF7,0x7B,0xBD,0xDE,  0xBD,0xDE,0xEF,0xF7,0x7B,  0x7B,0xF0,0xBD,0xDE,0xEF},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0x7B,0x7B,0x7B,0x7B,0x7B,  0xEF,0xEF,0xEF,0xEF,0xEF,  0xBD,0xBD,0xBD,0xBD,0xBD},
    								 	
    								 };
    	P1=0xff;
    	for(k=0;k<=10;k++)
    	{
    	for(j=0;j<=3;j++)
    	{
    		for(n=0;n<=6;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang[j][i]; P0=mang[j][i+5];P2=mang[j][i+10]; 
    				P3=mang[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  	 
    void quay_ngang4(void)
    {
    	char i,j,n,k;
    	unsigned char code mang[4][20]={{0xfE,0xfd,0xFB,0xF7,0xCF,  0xDE,0xBD,0x7B,0xF7,0xEF,  0x7B,0xF7,0xEF,0xDE,0xBD,  0xEF,0xDE,0xBD,0xF0,0x7B},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0x7B,0x7B,0x7B,0x7B,0x7B,  0xEF,0xEF,0xEF,0xEF,0xEF,  0xBD,0xBD,0xBD,0xBD,0xBD},
    								 {0xdE,0xfd,0xFB,0xF7,0xeF,  0xEF,0xF7,0x7B,0xBD,0xDE,  0xBD,0xDE,0xEF,0xF7,0x7B,  0x7B,0xF0,0xBD,0xDE,0xEF},
    								 {0xff,0xff,0xdB,0xff,0xfF,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00,  0x00,0x00,0x00,0x00,0x00},	
    								 };
    	P1=0xff;
    	for(k=0;k<=10;k++)
    	{
    	for(j=0;j<=3;j++)
    	{
    		for(n=0;n<=6;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang[j][i]; P0=mang[j][i+5];P2=mang[j][i+10]; 
    				P3=mang[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    }	  	 
    void traitim2(void)
    {
    	char i,j,n;
    	unsigned char code mang2[9][20]={{0xfE,0xfd,0xdB,0xd7,0xeF,  0xFF,0xFF,0xFF,0xff,0xff,  0xFF,0xFF,0xFF,0xff,0xff,  0xBF,0x5F,0xEF,0xAF,0x5F},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xff,0xff,  0xFF,0xFF,0x7F,0x7F,0xFF,  0xFD,0xFA,0xF7,0xF5,0xFA},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xff,0xff,  0xEF,0xD7,0xBB,0xAB,0xD7,  0xFF,0xFF,0xFF,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0x7F,0xBF,0xDF,0x5F,0xBF,  0xfF,0xFE,0xFD,0xFD,0xFE,  0xFF,0xFF,0xFF,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xEF,  0xFB,0xF5,0xEE,0xEA,0xF5,  0xFF,0xFF,0xFF,0xff,0xff,  0xFF,0xFF,0xFF,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0x7F,0xBF,0xDF,0x5F,0xBF,  0xfF,0xFE,0xFD,0xFD,0xFE,  0xFF,0xFF,0xFF,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xff,0xff,  0xEF,0xD7,0xBB,0xAB,0xD7,  0xFF,0xFF,0xFF,0xff,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xff,0xff,  0xFF,0xFF,0x7F,0x7F,0xFF,  0xFD,0xFA,0xF7,0xF5,0xFA},
    								 {0xfE,0xfd,0xdB,0xd7,0xeF,  0xFF,0xFF,0xFF,0xff,0xff,  0xFF,0xFF,0xFF,0xff,0xff,  0xBF,0x5F,0xEF,0xAF,0x5F},	
    								 };
    	P1=0xff;
    	for(j=0;j<=8;j++)
    	{
    		for(n=0;n<=30;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang2[j][i]; P0=mang2[j][i+5];P2=mang2[j][i+10]; 
    				P3=mang2[j][i+15]; delay(200);
    			}
    		}
    	}
    }
    /*void sangtoa2(void)
    {
    	char i,j,n,k;
    	unsigned char code mang2[8][20]={{0xff,0xff,0xfB,0xff,0xfF,  0xFF,0xFF,0xFF,0xff,0xff,  0xFF,0xFF,0xEF,0xff,0xff,  0xFF,0xFF,0xFF,0xff,0xff},
    								 {0xff,0xfd,0xfB,0xf7,0xfF,  0xFF,0xBF,0xFF,0xbf,0xff,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xFf,0xFA,0xFf,0xFA,0xFf},
    								 {0xfE,0xfd,0xfB,0xf7,0xcF,  0xEE,0xbF,0xFF,0xbF,0xEE,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xEF,0xFA,0xFf,0xFA,0xef},
    								 {0xfE,0xfd,0xff,0xf7,0xcF,  0xEE,0xbF,0xFF,0xbF,0xEE,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xEF,0xFA,0xFf,0xFA,0xef},
    								 {0xfE,0xff,0xff,0xff,0xcF,  0xEE,0xbF,0xFF,0xbF,0xEE,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xEF,0xFA,0xFf,0xFA,0xef},
    								 {0xfE,0xfd,0xff,0xf7,0xcF,  0xEE,0xbF,0xFF,0xbF,0xEE,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xEF,0xFA,0xFf,0xFA,0xef},
    								 {0xfE,0xfd,0xfB,0xf7,0xcF,  0xEE,0xbF,0xFF,0xbF,0xEE,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xEF,0xFA,0xFf,0xFA,0xef},
    								 {0xff,0xfd,0xfB,0xf7,0xff,  0xEE,0xbF,0xFF,0xbF,0xEE,  0xFF,0xFe,0xeF,0xFE,0xFF,  0xEF,0xFA,0xFf,0xFA,0xef},	
    								 };
    	for(k=0;k<=10;k++)
    	{
    	P1=0xff;
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=10;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang2[j][i]; P0=mang2[j][i+5];P2=mang2[j][i+10]; 
    				P3=mang2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    } 		   */
    void gay_quay(void)
    {
    	char i,j,n,k;
    	unsigned char code mang2[8][20]={{0xfe,0xfd,0xfB,0xf7,0xcF,  0xFE,0xBF,0xFF,0xff,0xff,  0xFF,0xFF,0xEF,0xff,0xff,  0xFF,0xFF,0xFF,0xFB,0xff},
    								 {0xfe,0xfd,0xfB,0xf7,0xEF,  0xFB,0x7F,0xFF,0xff,0xff,  0xFF,0xFf,0xEF,0xFf,0xFF,  0xFf,0xFf,0xFf,0xFD,0xBF},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xEF,0xFF,0xff,0xff,0xff,  0xFF,0xFE,0xEF,0xFf,0xFF,  0xfF,0xFf,0xFf,0xEF,0xFf},
    								 {0xfe,0xfd,0xfb,0xf7,0xeF,  0xff,0xff,0xFF,0xfF,0xff,  0xBF,0xDF,0xEF,0xF7,0xFB,  0xff,0xff,0xFF,0xfF,0xff},
    								 {0xdE,0xfd,0xfb,0xf7,0xeF,  0xff,0xfF,0xFF,0xBF,0xFE,  0xFF,0xFf,0xeF,0xFf,0xFF,  0xfF,0xFB,0xFf,0xFF,0xFF},
    								 {0xfE,0xfd,0xfb,0xf7,0xeF,  0xFF,0xFF,0xFF,0x7F,0xFB,  0xFF,0xFF,0xeF,0xFF,0xFF,  0xBF,0xFD,0xFF,0xFF,0xFF},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xFF,0xEF,  0xFF,0xFF,0xEF,0xFE,0xFF,  0xEF,0xFE,0xFF,0xFF,0xFF},
    								 {0xfe,0xfd,0xfB,0xf7,0xef,  0xFF,0xFF,0xFF,0xFF,0xFF,  0xFB,0xF7,0xEF,0xDF,0xBF,  0xFF,0xFF,0xFF,0xFF,0xFF},	
    								 };
    	for(k=0;k<=10;k++)
    	{
    	P1=0xff;
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=10;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang2[j][i]; P0=mang2[j][i+5];P2=mang2[j][i+10]; 
    				P3=mang2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    } 
    void gay_quay2(void)
    {
    	char i,j,n,k;
    	unsigned char code mang2[8][20]={{0xfe,0xfd,0xfB,0xf7,0xcF,  0xFE,0xBF,0xFF,0xff,0xff,  0xFF,0xFF,0xEF,0xff,0xff,  0xFF,0xFF,0xFF,0xFB,0xff},
    								 {0xfe,0xfd,0xfB,0xf7,0xef,  0xFF,0xFF,0xFF,0xFF,0xFF,  0xFB,0xF7,0xEF,0xDF,0xBF,  0xFF,0xFF,0xFF,0xFF,0xFF},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xFF,0xEF,  0xFF,0xFF,0xEF,0xFE,0xFF,  0xEF,0xFE,0xFF,0xFF,0xFF},
    								 {0xfE,0xfd,0xfb,0xf7,0xeF,  0xFF,0xFF,0xFF,0x7F,0xFB,  0xFF,0xFF,0xeF,0xFF,0xFF,  0xBF,0xFD,0xFF,0xFF,0xFF},
    								 {0xdE,0xfd,0xfb,0xf7,0xeF,  0xff,0xfF,0xFF,0xBF,0xFE,  0xFF,0xFf,0xeF,0xFf,0xFF,  0xfF,0xFB,0xFf,0xFF,0xFF},
    								 {0xfe,0xfd,0xfb,0xf7,0xeF,  0xff,0xff,0xFF,0xfF,0xff,  0xBF,0xDF,0xEF,0xF7,0xFB,  0xff,0xff,0xFF,0xfF,0xff},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xEF,0xFF,0xff,0xff,0xff,  0xFF,0xFE,0xEF,0xFf,0xFF,  0xfF,0xFf,0xFf,0xEF,0xFf},
    								 {0xfe,0xfd,0xfB,0xf7,0xEF,  0xFB,0x7F,0xFF,0xff,0xff,  0xFF,0xFf,0xEF,0xFf,0xFF,  0xFf,0xFf,0xFf,0xFD,0xBF},
    								 };
    	for(k=0;k<=10;k++)
    	{
    	P1=0xff;
    	for(j=0;j<=7;j++)
    	{
    		for(n=0;n<=10;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang2[j][i]; P0=mang2[j][i+5];P2=mang2[j][i+10]; 
    				P3=mang2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    } 
    /*void gay_quay3(void)
    {
    	char i,j,n,k;
    	unsigned char code mang2[9][20]={{0xfe,0xfd,0xfB,0xf7,0xcF,  0xFE,0xBF,0xFF,0xff,0xff,  0xFF,0xFF,0xEF,0xff,0xff,  0xFF,0xFF,0xFF,0xFB,0xff},
    								 {0xff,0xff,0xdB,0xff,0xff,  0xFF,0xFF,0xBE,0xFF,0xFF,  0xFB,0xF7,0xEF,0xDF,0xBF,  0xFF,0xFF,0xFB,0xFF,0xFF},
    								 {0xdE,0xfd,0xfb,0xf7,0xeF,  0xff,0xfF,0xFF,0xBF,0xFE,  0xFF,0xFf,0xeF,0xFf,0xFF,  0xfF,0xFB,0xFf,0xFF,0xFF},
    								 {0xfe,0xfd,0xfB,0xf7,0xef,  0xFF,0xFF,0xFF,0xFF,0xFF,  0xFB,0xF7,0xEF,0xDF,0xBF,  0xFF,0xFF,0xFF,0xFF,0xFF},
    								 {0xfe,0xfd,0xfB,0xf7,0xEF,  0xFB,0x7F,0xFF,0xff,0xff,  0xFF,0xFf,0xEF,0xFf,0xFF,  0xFf,0xFf,0xFf,0xFD,0xBF},
    								 {0xfe,0xfd,0xfb,0xf7,0xeF,  0xff,0xff,0xFF,0xfF,0xff,  0xBF,0xDF,0xEF,0xF7,0xFB,  0xff,0xff,0xFF,0xfF,0xff},
    								 {0xfE,0xfd,0xfb,0xf7,0xeF,  0xFF,0xFF,0xFF,0x7F,0xFB,  0xFF,0xFF,0xeF,0xFF,0xFF,  0xBF,0xFD,0xFF,0xFF,0xFF},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xFF,0xFF,0xFF,0xFF,0xEF,  0xFF,0xFF,0xEF,0xFE,0xFF,  0xEF,0xFE,0xFF,0xFF,0xFF},
    								 {0xfE,0xfd,0xfB,0xf7,0xeF,  0xEF,0xFF,0xff,0xff,0xff,  0xFF,0xFE,0xEF,0xFf,0xFF,  0xfF,0xFf,0xFf,0xEF,0xFf},
    								 };
    	for(k=0;k<=10;k++)
    	{
    	P1=0xff;
    	for(j=0;j<=8;j++)
    	{
    		for(n=0;n<=10;n++)// vong lap tao tre
    		{
    			for(i=0;i<=4;i++)
    			{
    				P1=mang2[j][i]; P0=mang2[j][i+5];P2=mang2[j][i+10]; 
    				P3=mang2[j][i+15]; delay(200);
    			}
    		}
    	}
    	}
    } */	 
    void main(void)
    {	
    	while(1)
    	{
    	chu_so();
    	traitim2();
    	trai_tim();
    	sau(); 
    	quay();
    	quay2();
    	quay_ngang();
    	quay_ngang2();
    	quay_ngang3();
    	quay_ngang4();	
    	sao();	
    	mua();
    	sang_toa();
    	chay_mang();
    	phao_hoa();
    	song();
    	song_ngang();
    	song_ngang2();
    	locxoay();
    	locxoay2();
    	gay_quay();
    	gay_quay2();	 
    	}	
    }

    Comment


    • #17
      làm led trái tim mà ko biết C thì dùng phần mềm leddimm đi bạn

      Comment


      • #18
        dạ em cảm ơn anh! giờ em hiểu đó là chuyển đổi!
        nhưng khi P0=0Xff vậy P0 sẽ ntn?(mức o hay 1)
        em cảm ơn[/QUOTE]

        bạn ơi at9c51 port p0 chỉ có mức 0v thôi bạn ạ


        MOV NHÀ,ANH
        MOV NHÀ,EM
        ADD ANH,EM

        Comment

        Về tác giả

        Collapse

        vanphu92 Tìm hiểu thêm về vanphu92

        Bài viết mới nhất

        Collapse

        Đang tải...
        X