pro nao giup em voi dich giup em file nay qua file hex voi em dich hoai khong dc
#include <REGX52.H>
sfr dk =0x90;
sfr ms =0xa0;
sfr dl =0xb0;
////////////////
#define ac 80 //thoi gian 1 so chay toi
#define ab 2 //thoi gian 1 led sang
#define aa 10
#define bb 200
////////////////
void delay(int t) //delay
{int i;
unsigned char b;
for (i=0;i<t;i++){for(b=0;b<125;b++){;}}
}
///////////////
void delay2(int t) //delay2
{int i;
for (i=0;i<t;i++);
}
//////////////
void dem123()
{unsigned char maso[9]={0x01,0x03,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80};
unsigned char a,b;
for(a=0;a<9;a++){dk =maso[a];
for(b=0;b<100;b++)
{ms =0x81;dl =0x7e;delay(ab);
ms =0x42;dl =0x81;delay(ab); //dem so 3
ms =0x2c;dl =0x01;delay(ab);
ms =0x10;dl =0x0f;delay(ab);
}
}
for(a=0;a<9;a++){dk =maso[a];
for(b=0;b<100;b++)
{ms =0x88;dl =0x3c;delay(ab);
ms =0x40;dl =0x42;delay(ab); //dem so 2
ms =0x70;dl =0x02;delay(ab);
ms =0x07;dl =0x40;delay(ab);
ms =0x01;dl =0x7e;delay(ab);
}
}
for(a=0;a<9;a++){dk =maso[a];
for(b=0;b<100;b++)
{ms =0x8e;dl =0x08;delay(ab); //dem so 1
ms =0x40;dl =0x18;delay(ab);
ms =0x20;dl =0x28;delay(ab);
ms =0x10;dl =0x48;delay(ab);
ms =0x01;dl =0x7e;delay(ab);
}
}
for(a=0;a<30;a++){dk =0xff;
for(b=0;b<20;b++)
{ms =0xaa;dl =0x55;delay(ab); //lap lanh
ms =0x55;dl =0xaa;delay(ab);
}
for(b=0;b<20;b++)
{ms =0xaa;dl =0xaa;delay(ab);
ms =0x55;dl =0x55;delay(ab);
}
}
}
/////////////////
void linhtinh()
{ unsigned char so[31]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,
0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,
0xf0,0xe1,0xc3,0x87,0x0f,
0xe0,0xc1,0x83,0x07};
unsigned char i,j;
for (i=0;i<8;i++) // sang quet tat
{ dk=so[i]; dl=0xff; ms= 0xff; delay(200);}
for (i=0;i<8;i++)
{ dl=so[i]; dk=0xff; ms= 0xff; delay(200);}
for (i=0;i<8;i++)
{ ms=so[i]; dk=0xff; dl= 0xff; delay(200);}
///////////////////
dk=0X00; dl=0X00; ms= 0x00; delay(500); //chop tat
dk=0XFF; dl=0xff; ms= 0xff; delay(400);
dk=0X00; dl=0X00; ms= 0x00; delay(400);
dk=0XFF; dl=0xff; ms= 0xff; delay(400);
///////////////////
for (i=8;i<16;i++) //sang het giam dan
{ dk=so[i]; delay(500) ; }
//////////////////
for(j=0;j<2;j++) //chay hinh hop
{for(i=15;i<10;i++)
{ dk=so[i];ms=so[i];dl =so[i]; delay(300);}
}
for(j=0;j<3;j++)
{for(i=21;i<27;i++)
{ dk=so[i];ms=so[i];dl =so[i]; delay(300);}
}
for(j=0;j<4;j++)
{for(i=26;i<31;i++)
{ dk=so[i];ms=so[i];dl =so[i]; delay(300);}
}
}
//////////////////////
void quetqualai ()
{ dk= 0xff,dl =0xff;
ms =0x01;delay(250);ms =0x03;delay(250);ms =0x06;delay(250);ms =0x0c;delay(250); //len
ms =0x18;delay(250);ms =0x30;delay(250);ms =0x60;delay(250);ms =0xc0;delay(250);ms =0x80;delay(250);
ms =0xc0;delay(250);ms =0x60;delay(250);ms =0x30;delay(250);ms =0x18;delay(250); //xuong
ms =0x0c;delay(250);ms =0x06;delay(250);ms =0x03;delay(250);ms =0x01;delay(250);
ms= 0xff;dl =0xff;
dk =0x01;delay(250);dk =0x03;delay(250);dk =0x06;delay(250);dk =0x0c;delay(250); //tientoi
dk =0x18;delay(250);dk =0x30;delay(250);dk =0x60;delay(250);dk =0xc0;delay(250);dk =0x80;delay(250);
dk =0xc0;delay(250);dk =0x60;delay(250);dk =0x30;delay(250);dk =0x18;delay(250); //tien lui
dk =0x0c;delay(250);dk =0x06;delay(250);dk =0x03;delay(250);dk =0x01;delay(250);
ms=0xff; dk =0xff;
dl =0xc0;delay(250);dl =0x60;delay(250);dl =0x30;delay(250);dl =0x18;delay(250); //qua phai
dl =0x0c;delay(250);dl =0x06;delay(250);dl =0x03;delay(250);dl =0x01;delay(250);
dl =0x03;delay(250);dl =0x06;delay(250);dl =0x0c;delay(250); //qua trai
dl =0x18;delay(250);dl =0x30;delay(250);dl =0x60;delay(250);dl =0xc0;delay(250);
}
/////////////////
void hinhvuong()
{unsigned char hv[32] ={0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,
0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,
0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,
0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,};
unsigned char i;
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);} //xuong qua phai
ms=0x00;dl=0x00;dk=0x00;
for(i=8;i<16;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);}
for(i=16;i<24;i++) //len qua trai
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);}
for(i=24;i<32;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);}
///////////////////
for(i=0;i<8;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i];delay(300);} //len qua phai
for(i=8;i<16;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i];delay(300);}
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i+16];delay(300);} //xuong qua trai
for(i=8;i<16;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i+16];delay(300);}
/////////////////////
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i];delay(300);} //xuong toi truoc
for(i=8;i<16;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i];delay(300);}
for(i=0;i<8;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i+16];delay(300);} //len ra sau
for(i=8;i<16;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i+16];delay(300);}
////////////////////
for(i=0;i<8;i++)
{ms= hv[i+16]; dk=hv[i+16];dl=hv[i];delay(300);} //len toi truoc
for(i=8;i<16;i++)
{ms= hv[i+16]; dk=hv[i+16];dl=hv[i];delay(300);}
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i+16];delay(300);} //xuong ra sau
for(i=0;i<8;i++)
{ms= hv[i+8]; dk=hv[i+8];dl=hv[i+24];delay(300);}
///////////////////
ms=0x7e;dl=0x7e,dk=0x7e;delay(700); //thu nho lai
ms=0x3c;dl=0x3c;dk=0x3c;delay(700);
ms=0x18;dl=0x18;dk=0x18;delay(700);
ms=0x00;dl=0x00;dk=0x00;delay(700);
}
/////////////////
void quetmangtatdan()
{unsigned char i,j;
unsigned char mg4[29] ={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xbf,0xdf,0xef,0xf7,0xfb,0xfd,
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
dl=0xff;dk=0xff;
ms=0x01;delay(300);
ms=0x03;delay(300);
ms=0x07;delay(300);
ms=0x0f;delay(300);
ms=0x1f;delay(300);
ms=0x3f;delay(300);
ms=0x7f;delay(300);
ms=0xff;delay(300);
for(i=0;i<5;i++)
{for(j=0;j<14;j++)
{ms=mg4[j];dl=mg4[j];dk=mg4[j+14];delay(300);
}
}
}
//////////////////
void sangmodan()
{unsigned int i,j;
ms=0xff;dk=0xff;
for(i=0;i<200;i++)
{for(j=0;j<5;j++)
{dl=0xff;delay2(i);
dl=0x00;delay2(200-i);
}
};
for(i=0;i<200;i++)
{for(j=0;j<5;j++)
{dl=0xff;delay2(200-i);
dl=0x00;delay2(i);
}
}
dl=0x00;delay2(300);
}
//////////////////
void mang1() {dl=0x01;}
void mang2() {dl=0x02;}
void mang3() {dl=0x04;}
void mang4() {dl=0x08;}
void mang5() {dl=0x10;}
void mang6() {dl=0x20;}
void mang7() {dl=0x40;}
void mang8() {dl=0x80;}
void manglenxuong()
{unsigned char i,j,k;
////////////////////////
unsigned char mg[21]={0x01,0x02,0x04,0x08,0x10,0x20,0x40, //xuong
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,
0x02,0x04,0x08,0x10,0x20,0x40 //len
};
unsigned char mg2[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, //xep len
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80};
unsigned char mg3[21]={0x80,0x80,0x80,0x80,
0x40,0x20,0x10,0x08,0x04,0x02,0x01, //xuong
0x01,0x01,0x01,
0x02,0x04,0x08,0x10,0x20,0x40,0x80 //len
};
for(i=0;i<15;i++)
{for(j=7;j<21;j++)
{for(k=0;k<10;k++)
{dk=0xff;
ms=mg[j]; mang1();delay(2); ///mang quet len xuong
ms=mg[j-1]; mang2();delay(2);
ms=mg[j-2]; mang3();delay(2);
ms=mg[j-3]; mang4();delay(2);
ms=mg[j-4]; mang5();delay(2);
ms=mg[j-5]; mang6();delay(2);
ms=mg[j-6]; mang7();delay(2);
ms=mg[j-7]; mang8();delay(2);
}
}
};
//////////////////////
for(j=7;j<16;j++)
{for(k=0;k<15;k++)
{dk=0xff;
ms=mg2[j]; mang1();delay(3); // mang tap trung len tren
ms=mg2[j-1]; mang2();delay(3);
ms=mg2[j-2]; mang3();delay(3);
ms=mg2[j-3]; mang4();delay(3);
ms=mg2[j-4]; mang5();delay(3);
ms=mg2[j-5]; mang6();delay(3);
ms=mg2[j-6]; mang7();delay(3);
ms=mg2[j-7]; mang8();delay(3);
}
};
/////////////////
for(i=0;i<10;i++)
{for(j=4;j<21;j++)
{for(k=0;k<15;k++)
{dk=0xff;
ms=mg3[j]; mang4();delay(2);mang5();delay(2); //canh chim bay
ms=mg3[j-1]; mang3();delay(2);mang6();delay(2);
ms=mg3[j-2]; mang2();delay(2);mang7();delay(2);
ms=mg3[j-3]; mang1();delay(2);mang8();delay(2);
}
}
};
ms=0x00;dl=0x00;dk=0x00;delay(500);
}
/////////////////
void so1() {dk =0x81;dl =0x81;delay(ab),dk =0x81;dl =0x81;delay(ab);}
void so2() {dk =0x42;dl =0x81;delay(ab),dk =0x81;dl =0x42;delay(ab);} //du lieu
void so3a() {dk =0x24;dl =0x81;delay(ab),dk =0x81;dl =0x24;delay(ab);}
void so3b() {dk =0x42;dl =0x42;delay(ab),dk =0x42;dl =0x42;delay(ab);}
void so4a() {dk =0x18;dl =0x81;delay(ab),dk =0x81;dl =0x18;delay(ab);}
void so4b() {dk =0x24;dl =0x42;delay(ab),dk =0x42;dl =0x24;delay(ab);}
void so5a() {dk =0x18;dl =0x42;delay(ab),dk =0x42;dl =0x18;delay(ab);}
void so5b() {dk =0x24;dl =0x24;delay(ab),dk =0x24;dl =0x24;delay(ab);}
void so6() {dk =0x18;dl =0x24;delay(ab),dk =0x24;dl =0x18;delay(ab);}
void so7() {dk =0x18;dl =0x18;delay(ab),dk =0x18;dl =0x18;delay(ab);}
/////////////////
/////////////////
void pheulenxuong()
{ unsigned char so[33]={0x10,0x08,0x04,0x02,0x01,0x01,0x01,0x01,0x01,
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, //len
0x80,0x80,0x80,0x80,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01, //xuong
0x01,0x01,0x01,0x01};
unsigned char a,c,b;
for(c=0;c<10;c++)
{for(a=10;a<33;a++)
{for(b=0;b<4;b++)
{ms= so[a]; so1();
ms= so[a-1]; so2();
ms= so[a-2]; so3a();
ms= so[a-3]; so3b();
ms= so[a-4]; so4a();
ms= so[a-5]; so4b();
ms= so[a-6]; so5a();
ms= so[a-7]; so5b();
ms= so[a-8]; so6();
ms= so[a-9]; so7();
ms= so[a-10]; so7();
}
}
}
}
//////////////////////////
void xoayvuong()
{unsigned char i,j;
for(i=0;i<200;i++) //so8
{ms =0x81;
dk=0x81; dl=0xff; delay(10);
dk=0xff; dl=0x81; delay(10);
ms =0xff;
dk=0x81; dl=0x81;delay(10);
};
for(j=0;j<10;j++)
{for(i=0;i<20;i++) //so8/2
{ms =0x42;
dk=0x42; dl=0x7e; delay(4);
dk=0x7e; dl=0x42; delay(4);
ms =0x7e;
dk=0x42; dl=0x42;delay(4);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay1
dk=0x42; dl=0x7e; delay(3);
dk=0x7e; dl=0x42; delay(3);
ms =0x7e;
dk=0x42; dl=0x42;delay(3);
dk=0x80; dl=0x04;delay(3);
dk=0x20; dl=0x80;delay(3);
dk=0x04; dl=0x01;delay(3);
dk=0x01; dl=0x20;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay2
dk=0x42; dl=0x3c; delay(3);
dk=0x24; dl=0x66; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x0c;delay(3);
dk=0x01; dl=0x30;delay(3);
dk=0x30; dl=0x80;delay(3);
dk=0x0c; dl=0x01;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay3
dk=0x42; dl=0x18; delay(3);
dk=0x24; dl=0x24; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x08;delay(3);
dk=0x10; dl=0x80;delay(3);
dk=0x08; dl=0x01;delay(3);
dk=0x01; dl=0x10;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay4
dk=0x42; dl=0x24; delay(3);
dk=0x24; dl=0x42; delay(3);
ms =0x7e;
dk=0x80; dl=0x18;delay(3);
dk=0x18; dl=0x81;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay5
dk=0x42; dl=0x18; delay(3);
dk=0x24; dl=0x24; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x10;delay(3);
dk=0x10; dl=0x01;delay(3);
dk=0x08; dl=0x80;delay(3);
dk=0x01; dl=0x08;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay6
dk=0x42; dl=0x3c; delay(3);
dk=0x24; dl=0x66; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x30;delay(3);
dk=0x01; dl=0x0c;delay(3);
dk=0x30; dl=0x01;delay(3);
dk=0x0c; dl=0x80;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay7
dk=0x42; dl=0x3c; delay(3);
dk=0x24; dl=0x66; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x20;delay(3);
dk=0x01; dl=0x04;delay(3);
dk=0x20; dl=0x01;delay(3);
dk=0x04; dl=0x80;delay(3);
};
}
}
//////////////////////////
void nhapnhay()
{ unsigned char i;
for(i=0;i<10;i++)
{ms=0x10;dk=0x10;dl=0x20;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x80;dk=0x10;dl=0x10;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x04;dk=0x20;dl=0x20;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x08;dk=0x02;dl=0x80;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x01;dk=0x40;dl=0x04;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x40;dk=0x80;dl=0x08;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x80;dk=0x04;dl=0x01;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb);
ms=0x02;dk=0x01;dl=0x40;delay(aa);
ms=0x00;dk=0x00;dl=0x00;delay(bb);
ms=0x08;dk=0x08;dl=0x04;delay(aa);
ms=0x00;dk=0x00;dl=0x00;delay(bb);
ms=0x01;dk=0x02;dl=0x20;delay(aa);
ms=0x00;dk=0x00;dl=0x00;delay(bb);
}
}
/////////////////////////
void muaroi()
{unsigned char so[22] ={0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,
0x00,0x00,0x00,0x00};
unsigned char i,j,k ;
for(k=0;k<10;k++)
{for(i=16;i<22;i++)
{for(j=0;j<3;j++)
{ms =so[i];
dl=0x88;dk=0x21;delay(10);
ms =so[i-1];
dl=0x12;dk=0x11;delay(10);
ms =so[i-2];
dl=0x42;dk=0xc4;delay(10);
ms =so[i-4];
dl=0x14;dk=0x54;delay(10);
ms =so[i-6];
dl=0x21;dk=0x22;delay(10);
ms =so[i-8];
dl=0x12;dk =0x22;delay(10);
ms =so[i-10];
dl=0x82;dk =0x14;delay(10);
}
}
}
}
////////////////////////
void banphaohoa()
{ unsigned int b;
unsigned char a,c;
unsigned char maso2[14]={0x80,0xc0,0x20,0x10,0x08,0x04,0x02,
0x01,0x00,0x00,0x00,0x00,0x00,0x00};
for(a=0;a<15;a++)
{dk=0x10;dl=0x10;
ms =0x03;delay(200); //chay len
ms =0x06;delay(200);
ms =0x0c;delay(200);
ms =0x18;delay(200);
ms =0x30;delay(200);
ms =0x60;delay(200);
dk=0x30;dl=0x30; //no23
ms =0xe0;delay(150);
dk=0x38;dl=0x38;
ms =0xe0;delay(150);
for(b=0;b<13;b++) //chuki 1
{ms =0x80;
dk =0x68;dl=0x40;delay(ab);
dk =0x0c;dl=0x20;delay(ab);
dk =0x54;dl=0x10;delay(ab);
dk =0x50;dl=0x08;delay(ab);
dk =0x2c;dl=0x04;delay(ab);
ms =0x40;
dk =0x38;dl=0x40;delay(ab);
dk =0x2a;dl=0x20;delay(ab);
dk =0x4a;dl=0x10;delay(ab);
dk =0x34;dl=0x08;delay(ab);
dk =0x14;dl=0x04;delay(ab);
ms =0x08;
dk =0x30;dl=0x20;delay(ab);
dk =0x28;dl=0x10;delay(ab);
dk =0x10;dl=0x08;delay(ab);
}
for(b=0;b<13;b++) //chuki2
{ms =0x80;
dk =0x24;dl=0x80;delay(ab);
dk =0x66;dl=0x40;delay(ab);
dk =0x14;dl=0x20;delay(ab);
dk =0x72;dl=0x10;delay(ab);
dk =0x96;dl=0x04;delay(ab);
dk =0xd8;dl=0x02;delay(ab);
ms =0x40;
dk =0x66;dl=0x40;delay(ab);
dk =0xe4;dl=0x20;delay(ab);
dk =0x38;dl=0x10;delay(ab);
dk =0x5a;dl=0x08;delay(ab);
dk =0xd8;dl=0x02;delay(ab);
ms =0x20;
dk =0x68;dl=0x40;delay(ab);
dk =0xe4;dl=0x10;delay(ab);
dk =0x5a;dl=0x08;delay(ab);
dk =0x26;dl=0x04;delay(ab);
ms =0x08;
dk =0x84;dl=0x20;delay(ab);
dk =0x72;dl=0x10;delay(ab);
dk =0x5a;dl=0x08;delay(ab);
}
for(c=5;c<14;c++) //no roi xuong
{
for(b=0;b<6;b++)
{ms =maso2[c];
dk =0x66;dl=0x40;delay(3);
dk =0x84;dl=0x20;delay(3);
dk =0x5a;dl=0x08;delay(3);
dk =0x16;dl=0x04;delay(3);
ms =maso2[c-2];
dk =0x81;dl=0x80;delay(3);
dk =0x24;dl=0x40;delay(3);
dk =0x51;dl=0x08;delay(3);
dk =0x88;dl=0x02;delay(3);
ms =maso2[c-3];
dk =0x44;dl=0x10;delay(3);
dk =0x44;dl=0x20;delay(3);
}
}
}
}
////////////////
void main ()
{ unsigned char k;
while (1)
{ for (k=0;k<1;k++)
{
dem123();
linhtinh();
quetqualai();
hinhvuong();
quetmangtatdan();
sangmodan();
manglenxuong();
pheulenxuong();
xoayvuong();
nhapnhay();
muaroi();
banphaohoa();
}
}
}
#include <REGX52.H>
sfr dk =0x90;
sfr ms =0xa0;
sfr dl =0xb0;
////////////////
#define ac 80 //thoi gian 1 so chay toi
#define ab 2 //thoi gian 1 led sang
#define aa 10
#define bb 200
////////////////
void delay(int t) //delay
{int i;
unsigned char b;
for (i=0;i<t;i++){for(b=0;b<125;b++){;}}
}
///////////////
void delay2(int t) //delay2
{int i;
for (i=0;i<t;i++);
}
//////////////
void dem123()
{unsigned char maso[9]={0x01,0x03,0x06,0x0c,0x18,0x30,0x60,0xc0,0x80};
unsigned char a,b;
for(a=0;a<9;a++){dk =maso[a];
for(b=0;b<100;b++)
{ms =0x81;dl =0x7e;delay(ab);
ms =0x42;dl =0x81;delay(ab); //dem so 3
ms =0x2c;dl =0x01;delay(ab);
ms =0x10;dl =0x0f;delay(ab);
}
}
for(a=0;a<9;a++){dk =maso[a];
for(b=0;b<100;b++)
{ms =0x88;dl =0x3c;delay(ab);
ms =0x40;dl =0x42;delay(ab); //dem so 2
ms =0x70;dl =0x02;delay(ab);
ms =0x07;dl =0x40;delay(ab);
ms =0x01;dl =0x7e;delay(ab);
}
}
for(a=0;a<9;a++){dk =maso[a];
for(b=0;b<100;b++)
{ms =0x8e;dl =0x08;delay(ab); //dem so 1
ms =0x40;dl =0x18;delay(ab);
ms =0x20;dl =0x28;delay(ab);
ms =0x10;dl =0x48;delay(ab);
ms =0x01;dl =0x7e;delay(ab);
}
}
for(a=0;a<30;a++){dk =0xff;
for(b=0;b<20;b++)
{ms =0xaa;dl =0x55;delay(ab); //lap lanh
ms =0x55;dl =0xaa;delay(ab);
}
for(b=0;b<20;b++)
{ms =0xaa;dl =0xaa;delay(ab);
ms =0x55;dl =0x55;delay(ab);
}
}
}
/////////////////
void linhtinh()
{ unsigned char so[31]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,
0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,
0xf0,0xe1,0xc3,0x87,0x0f,
0xe0,0xc1,0x83,0x07};
unsigned char i,j;
for (i=0;i<8;i++) // sang quet tat
{ dk=so[i]; dl=0xff; ms= 0xff; delay(200);}
for (i=0;i<8;i++)
{ dl=so[i]; dk=0xff; ms= 0xff; delay(200);}
for (i=0;i<8;i++)
{ ms=so[i]; dk=0xff; dl= 0xff; delay(200);}
///////////////////
dk=0X00; dl=0X00; ms= 0x00; delay(500); //chop tat
dk=0XFF; dl=0xff; ms= 0xff; delay(400);
dk=0X00; dl=0X00; ms= 0x00; delay(400);
dk=0XFF; dl=0xff; ms= 0xff; delay(400);
///////////////////
for (i=8;i<16;i++) //sang het giam dan
{ dk=so[i]; delay(500) ; }
//////////////////
for(j=0;j<2;j++) //chay hinh hop
{for(i=15;i<10;i++)
{ dk=so[i];ms=so[i];dl =so[i]; delay(300);}
}
for(j=0;j<3;j++)
{for(i=21;i<27;i++)
{ dk=so[i];ms=so[i];dl =so[i]; delay(300);}
}
for(j=0;j<4;j++)
{for(i=26;i<31;i++)
{ dk=so[i];ms=so[i];dl =so[i]; delay(300);}
}
}
//////////////////////
void quetqualai ()
{ dk= 0xff,dl =0xff;
ms =0x01;delay(250);ms =0x03;delay(250);ms =0x06;delay(250);ms =0x0c;delay(250); //len
ms =0x18;delay(250);ms =0x30;delay(250);ms =0x60;delay(250);ms =0xc0;delay(250);ms =0x80;delay(250);
ms =0xc0;delay(250);ms =0x60;delay(250);ms =0x30;delay(250);ms =0x18;delay(250); //xuong
ms =0x0c;delay(250);ms =0x06;delay(250);ms =0x03;delay(250);ms =0x01;delay(250);
ms= 0xff;dl =0xff;
dk =0x01;delay(250);dk =0x03;delay(250);dk =0x06;delay(250);dk =0x0c;delay(250); //tientoi
dk =0x18;delay(250);dk =0x30;delay(250);dk =0x60;delay(250);dk =0xc0;delay(250);dk =0x80;delay(250);
dk =0xc0;delay(250);dk =0x60;delay(250);dk =0x30;delay(250);dk =0x18;delay(250); //tien lui
dk =0x0c;delay(250);dk =0x06;delay(250);dk =0x03;delay(250);dk =0x01;delay(250);
ms=0xff; dk =0xff;
dl =0xc0;delay(250);dl =0x60;delay(250);dl =0x30;delay(250);dl =0x18;delay(250); //qua phai
dl =0x0c;delay(250);dl =0x06;delay(250);dl =0x03;delay(250);dl =0x01;delay(250);
dl =0x03;delay(250);dl =0x06;delay(250);dl =0x0c;delay(250); //qua trai
dl =0x18;delay(250);dl =0x30;delay(250);dl =0x60;delay(250);dl =0xc0;delay(250);
}
/////////////////
void hinhvuong()
{unsigned char hv[32] ={0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,
0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff,
0xff,0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,
0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff,};
unsigned char i;
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);} //xuong qua phai
ms=0x00;dl=0x00;dk=0x00;
for(i=8;i<16;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);}
for(i=16;i<24;i++) //len qua trai
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);}
for(i=24;i<32;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i];delay(300);}
///////////////////
for(i=0;i<8;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i];delay(300);} //len qua phai
for(i=8;i<16;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i];delay(300);}
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i+16];delay(300);} //xuong qua trai
for(i=8;i<16;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i+16];delay(300);}
/////////////////////
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i];delay(300);} //xuong toi truoc
for(i=8;i<16;i++)
{ms= hv[i]; dk=hv[i+16];dl=hv[i];delay(300);}
for(i=0;i<8;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i+16];delay(300);} //len ra sau
for(i=8;i<16;i++)
{ms= hv[i+16]; dk=hv[i];dl=hv[i+16];delay(300);}
////////////////////
for(i=0;i<8;i++)
{ms= hv[i+16]; dk=hv[i+16];dl=hv[i];delay(300);} //len toi truoc
for(i=8;i<16;i++)
{ms= hv[i+16]; dk=hv[i+16];dl=hv[i];delay(300);}
for(i=0;i<8;i++)
{ms= hv[i]; dk=hv[i];dl=hv[i+16];delay(300);} //xuong ra sau
for(i=0;i<8;i++)
{ms= hv[i+8]; dk=hv[i+8];dl=hv[i+24];delay(300);}
///////////////////
ms=0x7e;dl=0x7e,dk=0x7e;delay(700); //thu nho lai
ms=0x3c;dl=0x3c;dk=0x3c;delay(700);
ms=0x18;dl=0x18;dk=0x18;delay(700);
ms=0x00;dl=0x00;dk=0x00;delay(700);
}
/////////////////
void quetmangtatdan()
{unsigned char i,j;
unsigned char mg4[29] ={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0xbf,0xdf,0xef,0xf7,0xfb,0xfd,
0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
dl=0xff;dk=0xff;
ms=0x01;delay(300);
ms=0x03;delay(300);
ms=0x07;delay(300);
ms=0x0f;delay(300);
ms=0x1f;delay(300);
ms=0x3f;delay(300);
ms=0x7f;delay(300);
ms=0xff;delay(300);
for(i=0;i<5;i++)
{for(j=0;j<14;j++)
{ms=mg4[j];dl=mg4[j];dk=mg4[j+14];delay(300);
}
}
}
//////////////////
void sangmodan()
{unsigned int i,j;
ms=0xff;dk=0xff;
for(i=0;i<200;i++)
{for(j=0;j<5;j++)
{dl=0xff;delay2(i);
dl=0x00;delay2(200-i);
}
};
for(i=0;i<200;i++)
{for(j=0;j<5;j++)
{dl=0xff;delay2(200-i);
dl=0x00;delay2(i);
}
}
dl=0x00;delay2(300);
}
//////////////////
void mang1() {dl=0x01;}
void mang2() {dl=0x02;}
void mang3() {dl=0x04;}
void mang4() {dl=0x08;}
void mang5() {dl=0x10;}
void mang6() {dl=0x20;}
void mang7() {dl=0x40;}
void mang8() {dl=0x80;}
void manglenxuong()
{unsigned char i,j,k;
////////////////////////
unsigned char mg[21]={0x01,0x02,0x04,0x08,0x10,0x20,0x40, //xuong
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,
0x02,0x04,0x08,0x10,0x20,0x40 //len
};
unsigned char mg2[16]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, //xep len
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80};
unsigned char mg3[21]={0x80,0x80,0x80,0x80,
0x40,0x20,0x10,0x08,0x04,0x02,0x01, //xuong
0x01,0x01,0x01,
0x02,0x04,0x08,0x10,0x20,0x40,0x80 //len
};
for(i=0;i<15;i++)
{for(j=7;j<21;j++)
{for(k=0;k<10;k++)
{dk=0xff;
ms=mg[j]; mang1();delay(2); ///mang quet len xuong
ms=mg[j-1]; mang2();delay(2);
ms=mg[j-2]; mang3();delay(2);
ms=mg[j-3]; mang4();delay(2);
ms=mg[j-4]; mang5();delay(2);
ms=mg[j-5]; mang6();delay(2);
ms=mg[j-6]; mang7();delay(2);
ms=mg[j-7]; mang8();delay(2);
}
}
};
//////////////////////
for(j=7;j<16;j++)
{for(k=0;k<15;k++)
{dk=0xff;
ms=mg2[j]; mang1();delay(3); // mang tap trung len tren
ms=mg2[j-1]; mang2();delay(3);
ms=mg2[j-2]; mang3();delay(3);
ms=mg2[j-3]; mang4();delay(3);
ms=mg2[j-4]; mang5();delay(3);
ms=mg2[j-5]; mang6();delay(3);
ms=mg2[j-6]; mang7();delay(3);
ms=mg2[j-7]; mang8();delay(3);
}
};
/////////////////
for(i=0;i<10;i++)
{for(j=4;j<21;j++)
{for(k=0;k<15;k++)
{dk=0xff;
ms=mg3[j]; mang4();delay(2);mang5();delay(2); //canh chim bay
ms=mg3[j-1]; mang3();delay(2);mang6();delay(2);
ms=mg3[j-2]; mang2();delay(2);mang7();delay(2);
ms=mg3[j-3]; mang1();delay(2);mang8();delay(2);
}
}
};
ms=0x00;dl=0x00;dk=0x00;delay(500);
}
/////////////////
void so1() {dk =0x81;dl =0x81;delay(ab),dk =0x81;dl =0x81;delay(ab);}
void so2() {dk =0x42;dl =0x81;delay(ab),dk =0x81;dl =0x42;delay(ab);} //du lieu
void so3a() {dk =0x24;dl =0x81;delay(ab),dk =0x81;dl =0x24;delay(ab);}
void so3b() {dk =0x42;dl =0x42;delay(ab),dk =0x42;dl =0x42;delay(ab);}
void so4a() {dk =0x18;dl =0x81;delay(ab),dk =0x81;dl =0x18;delay(ab);}
void so4b() {dk =0x24;dl =0x42;delay(ab),dk =0x42;dl =0x24;delay(ab);}
void so5a() {dk =0x18;dl =0x42;delay(ab),dk =0x42;dl =0x18;delay(ab);}
void so5b() {dk =0x24;dl =0x24;delay(ab),dk =0x24;dl =0x24;delay(ab);}
void so6() {dk =0x18;dl =0x24;delay(ab),dk =0x24;dl =0x18;delay(ab);}
void so7() {dk =0x18;dl =0x18;delay(ab),dk =0x18;dl =0x18;delay(ab);}
/////////////////
/////////////////
void pheulenxuong()
{ unsigned char so[33]={0x10,0x08,0x04,0x02,0x01,0x01,0x01,0x01,0x01,
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80, //len
0x80,0x80,0x80,0x80,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01, //xuong
0x01,0x01,0x01,0x01};
unsigned char a,c,b;
for(c=0;c<10;c++)
{for(a=10;a<33;a++)
{for(b=0;b<4;b++)
{ms= so[a]; so1();
ms= so[a-1]; so2();
ms= so[a-2]; so3a();
ms= so[a-3]; so3b();
ms= so[a-4]; so4a();
ms= so[a-5]; so4b();
ms= so[a-6]; so5a();
ms= so[a-7]; so5b();
ms= so[a-8]; so6();
ms= so[a-9]; so7();
ms= so[a-10]; so7();
}
}
}
}
//////////////////////////
void xoayvuong()
{unsigned char i,j;
for(i=0;i<200;i++) //so8
{ms =0x81;
dk=0x81; dl=0xff; delay(10);
dk=0xff; dl=0x81; delay(10);
ms =0xff;
dk=0x81; dl=0x81;delay(10);
};
for(j=0;j<10;j++)
{for(i=0;i<20;i++) //so8/2
{ms =0x42;
dk=0x42; dl=0x7e; delay(4);
dk=0x7e; dl=0x42; delay(4);
ms =0x7e;
dk=0x42; dl=0x42;delay(4);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay1
dk=0x42; dl=0x7e; delay(3);
dk=0x7e; dl=0x42; delay(3);
ms =0x7e;
dk=0x42; dl=0x42;delay(3);
dk=0x80; dl=0x04;delay(3);
dk=0x20; dl=0x80;delay(3);
dk=0x04; dl=0x01;delay(3);
dk=0x01; dl=0x20;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay2
dk=0x42; dl=0x3c; delay(3);
dk=0x24; dl=0x66; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x0c;delay(3);
dk=0x01; dl=0x30;delay(3);
dk=0x30; dl=0x80;delay(3);
dk=0x0c; dl=0x01;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay3
dk=0x42; dl=0x18; delay(3);
dk=0x24; dl=0x24; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x08;delay(3);
dk=0x10; dl=0x80;delay(3);
dk=0x08; dl=0x01;delay(3);
dk=0x01; dl=0x10;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay4
dk=0x42; dl=0x24; delay(3);
dk=0x24; dl=0x42; delay(3);
ms =0x7e;
dk=0x80; dl=0x18;delay(3);
dk=0x18; dl=0x81;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay5
dk=0x42; dl=0x18; delay(3);
dk=0x24; dl=0x24; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x10;delay(3);
dk=0x10; dl=0x01;delay(3);
dk=0x08; dl=0x80;delay(3);
dk=0x01; dl=0x08;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay6
dk=0x42; dl=0x3c; delay(3);
dk=0x24; dl=0x66; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x30;delay(3);
dk=0x01; dl=0x0c;delay(3);
dk=0x30; dl=0x01;delay(3);
dk=0x0c; dl=0x80;delay(3);
};
for(i=0;i<20;i++) //so8/2
{ms =0x42; //xoay7
dk=0x42; dl=0x3c; delay(3);
dk=0x24; dl=0x66; delay(3);
dk=0x18; dl=0x42;delay(3);
ms =0x7e;
dk=0x80; dl=0x20;delay(3);
dk=0x01; dl=0x04;delay(3);
dk=0x20; dl=0x01;delay(3);
dk=0x04; dl=0x80;delay(3);
};
}
}
//////////////////////////
void nhapnhay()
{ unsigned char i;
for(i=0;i<10;i++)
{ms=0x10;dk=0x10;dl=0x20;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x80;dk=0x10;dl=0x10;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x04;dk=0x20;dl=0x20;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x08;dk=0x02;dl=0x80;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x01;dk=0x40;dl=0x04;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x40;dk=0x80;dl=0x08;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb) ;
ms=0x80;dk=0x04;dl=0x01;delay(aa) ;
ms=0x00;dk=0x00;dl=0x00;delay(bb);
ms=0x02;dk=0x01;dl=0x40;delay(aa);
ms=0x00;dk=0x00;dl=0x00;delay(bb);
ms=0x08;dk=0x08;dl=0x04;delay(aa);
ms=0x00;dk=0x00;dl=0x00;delay(bb);
ms=0x01;dk=0x02;dl=0x20;delay(aa);
ms=0x00;dk=0x00;dl=0x00;delay(bb);
}
}
/////////////////////////
void muaroi()
{unsigned char so[22] ={0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0 0,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,
0x00,0x00,0x00,0x00};
unsigned char i,j,k ;
for(k=0;k<10;k++)
{for(i=16;i<22;i++)
{for(j=0;j<3;j++)
{ms =so[i];
dl=0x88;dk=0x21;delay(10);
ms =so[i-1];
dl=0x12;dk=0x11;delay(10);
ms =so[i-2];
dl=0x42;dk=0xc4;delay(10);
ms =so[i-4];
dl=0x14;dk=0x54;delay(10);
ms =so[i-6];
dl=0x21;dk=0x22;delay(10);
ms =so[i-8];
dl=0x12;dk =0x22;delay(10);
ms =so[i-10];
dl=0x82;dk =0x14;delay(10);
}
}
}
}
////////////////////////
void banphaohoa()
{ unsigned int b;
unsigned char a,c;
unsigned char maso2[14]={0x80,0xc0,0x20,0x10,0x08,0x04,0x02,
0x01,0x00,0x00,0x00,0x00,0x00,0x00};
for(a=0;a<15;a++)
{dk=0x10;dl=0x10;
ms =0x03;delay(200); //chay len
ms =0x06;delay(200);
ms =0x0c;delay(200);
ms =0x18;delay(200);
ms =0x30;delay(200);
ms =0x60;delay(200);
dk=0x30;dl=0x30; //no23
ms =0xe0;delay(150);
dk=0x38;dl=0x38;
ms =0xe0;delay(150);
for(b=0;b<13;b++) //chuki 1
{ms =0x80;
dk =0x68;dl=0x40;delay(ab);
dk =0x0c;dl=0x20;delay(ab);
dk =0x54;dl=0x10;delay(ab);
dk =0x50;dl=0x08;delay(ab);
dk =0x2c;dl=0x04;delay(ab);
ms =0x40;
dk =0x38;dl=0x40;delay(ab);
dk =0x2a;dl=0x20;delay(ab);
dk =0x4a;dl=0x10;delay(ab);
dk =0x34;dl=0x08;delay(ab);
dk =0x14;dl=0x04;delay(ab);
ms =0x08;
dk =0x30;dl=0x20;delay(ab);
dk =0x28;dl=0x10;delay(ab);
dk =0x10;dl=0x08;delay(ab);
}
for(b=0;b<13;b++) //chuki2
{ms =0x80;
dk =0x24;dl=0x80;delay(ab);
dk =0x66;dl=0x40;delay(ab);
dk =0x14;dl=0x20;delay(ab);
dk =0x72;dl=0x10;delay(ab);
dk =0x96;dl=0x04;delay(ab);
dk =0xd8;dl=0x02;delay(ab);
ms =0x40;
dk =0x66;dl=0x40;delay(ab);
dk =0xe4;dl=0x20;delay(ab);
dk =0x38;dl=0x10;delay(ab);
dk =0x5a;dl=0x08;delay(ab);
dk =0xd8;dl=0x02;delay(ab);
ms =0x20;
dk =0x68;dl=0x40;delay(ab);
dk =0xe4;dl=0x10;delay(ab);
dk =0x5a;dl=0x08;delay(ab);
dk =0x26;dl=0x04;delay(ab);
ms =0x08;
dk =0x84;dl=0x20;delay(ab);
dk =0x72;dl=0x10;delay(ab);
dk =0x5a;dl=0x08;delay(ab);
}
for(c=5;c<14;c++) //no roi xuong
{
for(b=0;b<6;b++)
{ms =maso2[c];
dk =0x66;dl=0x40;delay(3);
dk =0x84;dl=0x20;delay(3);
dk =0x5a;dl=0x08;delay(3);
dk =0x16;dl=0x04;delay(3);
ms =maso2[c-2];
dk =0x81;dl=0x80;delay(3);
dk =0x24;dl=0x40;delay(3);
dk =0x51;dl=0x08;delay(3);
dk =0x88;dl=0x02;delay(3);
ms =maso2[c-3];
dk =0x44;dl=0x10;delay(3);
dk =0x44;dl=0x20;delay(3);
}
}
}
}
////////////////
void main ()
{ unsigned char k;
while (1)
{ for (k=0;k<1;k++)
{
dem123();
linhtinh();
quetqualai();
hinhvuong();
quetmangtatdan();
sangmodan();
manglenxuong();
pheulenxuong();
xoayvuong();
nhapnhay();
muaroi();
banphaohoa();
}
}
}
Comment