Mạch trái tim là một mạch khá cơ bản và dễ thực hiện, nhưng cái khó là để có thể code được những hiệu ứng đẹp mắt.
Hiện tại thì rất nhiều bạn có thể làm mạch trái tim từ các trang mạng, nhưng đa số code các bạn nhận được là File .Hex. Do đó rất khó có thể hiệu chỉnh lại theo ý mình.
// Chuong trinh LED trai tim 44 hieu ung
// Designed by Tuan
// Email: Phantuan.ktd@gmail.com
// Website: studyeit.blogspot.com
#include <REG52.H>
#include<stdio.h>
#include<intrins.h>
unsigned int i,j,k;
//****************Ham tao thoi gian tre 0,5s************************
void delay(unsigned int ms)
{
unsigned int a;
unsigned char b;
for(a=0; a<ms; a++)
{
for(b=0; b<125; b++)
{
}
}
}
//*********************Hieu ung nhay toan bo************************
void hieu_ung_1(void)
{
for(k=0; k<8; k++)
{
P0=P1=P2=P3=1;
delay(300);
P0=P1=P2=P3=0;
delay(300);
}
}
//*****************Hieu ung nhay 2 nua trai tim*********************
void hieu_ung_2(void)
{
for(i=0; i<6; i++)
{
P0=P3=0;
delay(300);
P0=P3=1;
P1=P2=0;
delay(300);
P1=P2=1;
}
}
//*********************Hieu ung nhay so le************************
void hieu_ung_3(void)
{
for(i=0; i<8; i++)
{
P0=P1=P2=P3=0x55;
delay(300);
P0=P1=P2=P3=0xaa;
delay(300);
}
}
//*********************Hieu ung nhay so le 2***********************
void hieu_ung_4(void)
{
for(i=0; i<8; i++)
{
P0=P1=P2=P3=0xaa;
delay(300);
P0=P1=P2=P3=0x55;
delay(300);
}
}
//*********************Cung sang thuan******************************
void hieu_ung_5(void)
{
unsigned char x,y;
x=y=255;
i=1;
j=128;
for(k=0; k<8; k++)
{
x=x-i;
y=y-j;
P0=x;
P1=P2=P3=y;
i=i*2;
j=j/2;
delay(300);
}
}
//*********************Cung sang nghich******************************
void hieu_ung_6(void)
{
unsigned char x,y;
x=y=255;
i=1;
j=128;
for(k=0; k<8; k++)
{
x=x-i;
y=y-j;
P0=y;
P1=P2=P3=x;
i=i*2;
j=j/2;
delay(300);
}
}
//*********************Sang lan luot cac LED thuan********************
void hieu_ung_7(void)
{
unsigned char M[]= {0XFE,0XFC,0XF8,0XF0,0XE0,0XC0,0X80,0X00};
unsigned char N[]= {0X7F,0X3F,0X1F,0X0F,0X07,0X03,0X01,0X00};
P0=P1=P2=P3=1;
for(i=0; i<8; i++)
{
P0=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P1=N[i];
delay(300);
}
}
//***********************Tat lan luot cac LED thuan********************
void hieu_ung_8(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0;
for(i=0; i<8; i++)
{
P0=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P1=N[i];
delay(300);
}
}
//********************Sang lan luot het cac LED thuan*******************
void hieu_ung_9(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=1;
for(i=0; i<8; i++)
{
P1=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=N[i];
delay(300);
}
}
//********************Tat lan luot het cac LED thuan*******************
void hieu_ung_10(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0;
for(i=0; i<8; i++)
{
P1=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=N[i];
delay(300);
}
}
//************************Hieu ung dac biet 1*************************
void hieu_ung_11(void)
{
unsigned char M[]= {0XF0,0XE1,0XC3,0X87,0X0F};
/* 1 1 1 1 0 0 0 0
1 1 1 0 0 0 0 1
1 1 0 0 0 0 1 1
1 0 0 0 0 1 1 1
0 0 0 0 1 1 1 1 */
unsigned char N[]= {0x0f,0x4f,0x63,0x71,0x78};
/* 0 0 0 0 1 1 1 1
0 0 1 0 1 1 1 1
0 1 1 0 0 0 1 1
0 1 1 1 0 0 0 1
0 1 1 1 1 0 0 0
*/
unsigned char L[]= {0x1f,0x4f,0x6f,0x73,0x79,0x7c};
/* 0 0 0 1 1 1 1 1
0 1 0 0 1 1 1 1
0 1 1 0 1 1 1 1
0 1 1 1 0 0 1 1
0 1 1 1 1 0 0 1
0 1 1 1 1 1 0 0
*/
unsigned char K[]= {0x3f,0x5f,0x6f,0x77,0x7b,0x7d,0x7e};
/* 0 0 1 1 1 1 1 1
0 1 0 1 1 1 1 1
0 1 1 0 1 1 1 1
0 1 1 1 0 1 1 1
0 1 1 1 1 0 1 1
0 1 1 1 1 1 0 1
0 1 1 1 1 1 1 0
*/
P0=P1=P2=P3=1;
for(i=0; i<5; i++)
{
P0=M[i];
delay(300);
}
P0=0xff;
for(i=0; i<5; i++)
{
P2=N[i];
delay(300);
}
P2=0x7f;
for(i=0; i<6; i++)
{
P3=L[i];
delay(300);
}
P2=P3=0x7f;
for(i=0; i<7; i++)
{
P1=K[i];
delay(300);
}
P1=P2=P3=0x7f;
}
//************************Hieu ung dac biet 2*************************
void hieu_ung_12(void)
{
unsigned char M[]= {0xf0,0xe1,0xc3,0x87,0x0f};
unsigned char N[]= {0xf0,0xe2,0xc6,0x8e,0x1e};
unsigned char L[]= {0xf8,0xf2,0xe6,0xce,0x9e,0x3e};
unsigned char K[]= {0x3f,0x5f,0x6f,0x77,0x7b,0x7d,0x7e};
P0=P1=P2=P3=1;
for(i=0; i<5; i++)
{
P1=M[i];
delay(300);
}
P1=0xff;
for(i=0; i<5; i++)
{
P3=N[i];
delay(300);
}
P3=0xfe;
for(i=0; i<6; i++)
{
P2=L[i];
delay(300);
}
P2=P3=0xfe;
for(i=0; i<7; i++)
{
P0=K[i];
delay(300);
}
P0=0x7f;
P2=P3=0xfe;
}
//************************Hieu ung dac biet 3*************************
void hieu_ung_13(void)
{
unsigned char M[]= {0xf8,0xf2,0xe6,0xce,0x9e,0x3e};
unsigned char N[]= {0x1f,0x4f,0x67,0x73,0x79,0x7c};
P0=P1=P2=P3=0;
for(i=0; i<6; i++)
{
P3=P2=P1=N[i];
P0=M[i];
delay(300);
}
}
//************************Hieu ung dac biet 4*************************
void hieu_ung_14(void)
{
unsigned char M[]= {0xf8,0xf2,0xe6,0xce,0x9e,0x3e};
unsigned char N[]= {0x1f,0x4f,0x67,0x73,0x79,0x7c};
P0=P1=P2=P3=0;
for(i=0; i<6; i++)
{
P3=P2=P1=M[i];
P0=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 1*************************
void hieu_ung_15(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=1;
for(i=0; i<8; i++)
{
P2=M[i];
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=P1=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 2*************************
void hieu_ung_16(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=1;
for(i=0; i<8; i++)
{
P0=P1=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=N[i];
P3=M[i];
delay(300);
}
}
//************************Sang dan het cac LED 3*************************
void hieu_ung_17(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P0=P2=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P1=M[i];
P3=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 4*************************
void hieu_ung_18(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P1=N[i];
P3=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=P2=M[i];
delay(300);
}
}
//************************Sang dan het cac LED 5*************************
void hieu_ung_19(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P2=N[i];
P3=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=P1=M[i];
delay(300);
}
}
//************************Sang dan het cac LED 6*************************
void hieu_ung_20(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P0=P1=P2=M[i];
P3=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 7*************************
void hieu_ung_21(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P0=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P1=M[i];
delay(300);
}
}
//************************Sang dan het cac LED 8*************************
void hieu_ung_22(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P1=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 9*************************
void hieu_ung_23(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P0=P2=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P1=M[i];
P3=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 10*************************
void hieu_ung_24(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P0=M[i];
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P2=P1=N[i];
delay(300);
}
}
//************************Sang dan het cac LED 11*************************
void hieu_ung_25(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P2=P1=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=N[i];
P3=M[i];
delay(300);
}
}
//**************************Tat het cac LED 1***************************
void hieu_ung_26(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0; i<8; i++)
{
P0=P1=M[i];
delay(300);
}
for(i=0; i<8; i++)
{
P3=M[i];
P2=N[i];
delay(300);
}
}
//**************************Tat het cac LED 2***************************
void hieu_ung_27(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0; i<8; i++)
{
P2=M[i];
P3=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=P1=N[i];
delay(300);
}
}
//**************************Tat het cac LED 3***************************
void hieu_ung_28(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0; i<8; i++)
{
P3=M[i];
P1=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P0=P2=M[i];
delay(300);
}
}
//**************************Tat het cac LED 4***************************
void hieu_ung_45(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0; i<8; i++)
{
P0=P2=N[i];
delay(300);
}
for(i=0; i<8; i++)
{
P1=M[i];
P3=N[i];
delay(300);
}
}
//**************************Tat het cac LED 5***************************
void hieu_ung_29(void)
{
unsigned char M[]= {0x00,0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0; i<9; i++)
{
P0=P2=P1=N[i];
P3=M[i];
delay(300);
}
}
//*******************************Quet 3 LED*****************************
void hieu_ung_30(void)
{
unsigned char M[]= {0xf8,0xf1,0xe3,0xc7,0x8f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x1f,0x8f,0xc7,0xe3,0xf1,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P0=M[i];
delay(300);
}
P0=0xff;
for(i=0; i<6; i++)
{
P2=N[i];
delay(300);
}
P2=0xff;
for(i=0; i<6; i++)
{
P3=N[i];
delay(300);
}
P3=0xff;
for(i=0; i<6; i++)
{
P1=N[i];
delay(300);
}
P1=0xff;
for(i=0; i<6; i++)
{
P1=M[i];
delay(300);
}
P1=0xff;
for(i=0; i<6; i++)
{
P3=M[i];
delay(300);
}
P3=0xff;
for(i=0; i<6; i++)
{
P2=M[i];
delay(300);
}
P2=0xff;
for(i=0; i<6; i++)
{
P0=N[i];
delay(300);
}
P0=0xff;
for(i=0; i<6; i++)
{
P0=M[i];
P1=M[i];
delay(300);
}
P0=P1=0xff;
for(i=0; i<9; i++)
{
P2=N[i];
P3=M[i];
delay(300);
}
P2=P3=0xff;
for(i=0; i<6; i++)
{
P2=M[i];
P3=N[i];
delay(300);
}
P3=P2=0xff;
for(i=0; i<9; i++)
{
P0=N[i];
P1=N[i];
delay(300);
}
P1=P0=0xff;
}
//########## SANG TANG DAN TAT CA CAC LED SO LE NHAU 1 #############
void hieu_ung_31(void)
{
unsigned char M[]= {0xfe,0xf5,0xea,0xd5,0xaa,0x55};
unsigned char N[]= {0x7f,0xaf,0x57,0xab,0x55,0xaa};
unsigned char L[]= {0x55,0xaa};
unsigned char K[]= {0xaa,0x55};
unsigned char H[]= {0xaa,0x55};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P0=M[i];
delay(300);
}
for(i=0; i<6; i++)
{
P0=L[i];
P2=N[i];
delay(300);
}
for(i=0; i<6; i++)
{
P2=H[i];
P0=L[i];
P3=N[i];
delay(300);
}
for(i=0; i<6; i++)
{
P0=L[i];
P2=H[i];
P3=K[i];
P1=N[i];
delay(300);
}
}
//########## SANG TANG DAN TAT CA CAC LED SO LE NHAU 2 #############
void hieu_ung_32(void)
{
unsigned char M[]= {0xfe,0xf5,0xea,0xd5,0xaa,0x55};
unsigned char N[]= {0x7f,0xaf,0x57,0xab,0x55,0xaa};
unsigned char L[]= {0x55,0xaa};
unsigned char K[]= {0xaa,0x55};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P1=M[i];
delay(300);
}
for(i=0; i<6; i++)
{
P1=L[i];
P3=M[i];
delay(300);
}
for(i=0; i<6; i++)
{
P1=P3=L[i];
P2=M[i];
delay(300);
}
for(i=0; i<6; i++)
{
P1=P2=P3=L[i];
P0=N[i];
delay(300);
}
}
//########## SANG TANG DAN TAT CA CAC LED SO LE NHAU 3 #############
void hieu_ung_33(void)
{
unsigned char M[]= {0xfe,0xf5,0xea,0xd5,0xaa,0x55};
unsigned char N[]= {0x7f,0xaf,0x57,0xab,0x55,0xaa};
unsigned char L[]= {0x55,0xaa};
unsigned char K[]= {0xaa,0x55};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P2=M[i];
P3=N[i];
delay(300);
}
for(i=0; i<6; i++)
{
P2=L[i];
P3=K[i];
P0=P1=N[i];
delay(300);
}
}
//########## SANG TANG DAN TAT CA CAC LED SO LE NHAU 4 #############
void hieu_ung_34(void)
{
unsigned char M[]= {0xfe,0xf5,0xea,0xd5,0xaa,0x55};
unsigned char N[]= {0x7f,0xaf,0x57,0xab,0x55,0xaa};
unsigned char L[]= {0x55,0xaa};
unsigned char K[]= {0xaa,0x55};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P0=P1=M[i];
delay(300);
}
for(i=0; i<6; i++)
{
P0=P1=L[i];
P2=N[i];
P3=M[i];
delay(300);
}
}
//########## SANG TANG DAN TAT CA CAC LED SO LE NHAU 5 #############
void hieu_ung_35(void)
{
unsigned char M[]= {0xfe,0xf5,0xea,0xd5,0xaa,0x55};
unsigned char N[]= {0x7f,0xaf,0x57,0xab,0x55,0xaa};
unsigned char L[]= {0x55,0xaa};
unsigned char K[]= {0xaa,0x55};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P0=P2=N[i];
delay(300);
}
for(i=0; i<6; i++)
{
P0=P2=K[i];
P1=M[i];
P3=N[i];
delay(300);
}
}
//##########SANG TANG DAN TAT CA CAC LED SO LE NHAU 6 ##############
void hieu_ung_36(void)
{
unsigned char M[]= {0xfe,0xf5,0xea,0xd5,0xaa,0x55};
unsigned char N[]= {0x7f,0xaf,0x57,0xab,0x55,0xaa};
unsigned char L[]= {0x55,0xaa};
unsigned char K[]= {0xaa,0x55};
P0=P1=P2=P3=0xff;
for(i=0; i<6; i++)
{
P1=N[i];
P3=M[i];
delay(300);
}
for(i=0; i<6; i++)
{
P1=K[i];
P3=L[i];
P0=P2=M[i];
delay(300);
}
}
//########## HIEU UNG DONG HO TICH TAC 1 ###########################
void hieu_ung_37(void)
{
unsigned char M[]= {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0x7e,0x7d,0x7b,0x77,0x6f,0x5f,0x3f,0x3e,
0x3d,0x3b,0x37,0x2f,0x1f,0x1e,0x1d,0x1b,
0x17,0x0f,0x0e,0x0d,0x0b,0x07,0x06,0x05,
0x03,0x02,0x01,0x00
};
unsigned char N[]= {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0x7e,0xbe,0xde,0xee,0xf6,0xfa,0xfc,0x7c,
0xbc,0xdc,0xec,0xf4,0xf8,0x78,0xb8,0xd8,
0xe8,0xf0,0x70,0xb0,0xd0,0xe0,0x60,0xa0,
0xc0,0x40,0x80,0x00
};
for(i=0; i<36; i++)
{
P0=M[i];
P1=P2=P3=N[i];
delay(400);
}
}
//########## HIEU UNG DONG HO TICH TAC 2 ###########################
void hieu_ung_38(void)
{
unsigned char M[]= {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,
0x7e,0x7d,0x7b,0x77,0x6f,0x5f,0x3f,0x3e,
0x3d,0x3b,0x37,0x2f,0x1f,0x1e,0x1d,0x1b,
0x17,0x0f,0x0e,0x0d,0x0b,0x07,0x06,0x05,
0x03,0x02,0x01,0x00
};
unsigned char N[]= {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,
0x7e,0xbe,0xde,0xee,0xf6,0xfa,0xfc,0x7c,
0xbc,0xdc,0xec,0xf4,0xf8,0x78,0xb8,0xd8,
0xe8,0xf0,0x70,0xb0,0xd0,0xe0,0x60,0xa0,
0xc0,0x40,0x80,0x00
};
for(i=0; i<36; i++)
{
P0=N[i];
P1=P2=P3=M[i];
delay(400);
}
}
//########## HIEU UNG DONG HO TICH TAC 3 ###########################
void hieu_ung_39()
{
unsigned char L[]= {0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,
0x80,0x81,0x82,0x84,0x88,0x90,0xa0,0xc0,
0xc1,0xc2,0xc4,0xc8,0xd0,0xe0,0xe1,0xe2,
0xe4,0xe8,0xf0,0xf1,0xf2,0xf4,0xf8,0xf9,
0xfa,0xfc,0xfd,0xfe,0xff
};
unsigned char K[]= {0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,
0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,
0x83,0x43,0x23,0x13,0x0b,0x07,0x87,0x47,
0x27,0x17,0x0f,0x8f,0x4f,0x2f,0x1f,0x9f,
0x5f,0x3f,0xbf,0x7f,0xff
};
for(i=0; i<37; i++)
{
P0=L[i];
P1=P2=P3=K[i];
delay(400);
}
}
//##################################################################
//########## HIEU UNG DONG HO TICH TAC 4 ###########################
void hieu_ung_40()
{
unsigned char L[]= {0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,
0x80,0x81,0x82,0x84,0x88,0x90,0xa0,0xc0,
0xc1,0xc2,0xc4,0xc8,0xd0,0xe0,0xe1,0xe2,
0xe4,0xe8,0xf0,0xf1,0xf2,0xf4,0xf8,0xf9,
0xfa,0xfc,0xfd,0xfe,0xff
};
unsigned char K[]= {0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,
0x01,0x81,0x41,0x21,0x11,0x09,0x05,0x03,
0x83,0x43,0x23,0x13,0x0b,0x07,0x87,0x47,
0x27,0x17,0x0f,0x8f,0x4f,0x2f,0x1f,0x9f,
0x5f,0x3f,0xbf,0x7f,0xff
};
for(i=0; i<37; i++)
{
P0=K[i];
P1=P2=P3=L[i];
delay(400);
}
}
//##################################################################
//########## TANG DAN LED 2 NUA TRAI TIM ###########################
void hieu_ung_41(void)
{
unsigned char M[]= {0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]= {0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0; i<8; i++)
{
P0=M[i];
P3=N[i];
delay(2500);
}
for(i=0; i<8; i++)
{
P2=P1=N[i];
delay(2500);
}
}
//##################################################################
//########## GIAM DAN LED 2 NUA TRAI TIM ###########################
void hieu_ung_42(void)
{
unsigned char M[]= {0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]= {0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0; i<8; i++)
{
P2=P1=M[i];
delay(2500);
}
for(i=0; i<8; i++)
{
P0=N[i];
P3=M[i];
delay(2500);
}
}
//##################################################################
//########## QUET 3 LED MOI VIET 1 #################################
void hieu_ung_43()
{
P2=0xf8;
delay(300);
P2=0xf1;
delay(300);
P2=0xe3;
delay(300);
P2=0xc7;
delay(300);
P2=0x8f;
delay(300);
P2=0x1f;
delay(300);
P2=0xff;
P0=0x1f;
delay(300);
P0=0x47;
delay(300);
P0=0x63;
delay(300);
P0=0x71;
delay(300);
P0=0x78;
delay(300);
P0=0x7f;
P1=0xf8;
delay(300);
P1=0xe2;
delay(300);
P1=0xc6;
delay(300);
P1=0x8e;
delay(300);
P1=0x1e;
delay(300);
P0=0x7f;
P1=0xfe;
P3=0xf8;
delay(300);
P3=0xe2;
delay(300);
P3=0xc6;
delay(300);
P3=0x8e;
delay(300);
P3=0x1e;
delay(300);
}
//##################################################################
//########## QUET 3 LED MOI VIET 2 #################################
void hieu_ung_44()
{
P0=P1=P2=P3=0xff;
P1=0xfe;
P0=0x7f;
P3=0x1e;
delay(300);
P3=0x8e;
delay(300);
P3=0xc6;
delay(300);
P3=0xe2;
delay(300);
P3=0xf8;
delay(300);
P3=0xfe;
P1=0x1e;
delay(300);
P1=0x8e;
delay(300);
P1=0xc6;
delay(300);
P1=0xe2;
delay(300);
P1=0xf8;
delay(300);
P1=0xfe;
P0=0x78;
delay(300);
P0=0x71;
delay(300);
P0=0x63;
delay(300);
P0=0x47;
delay(300);
P0=0x1f;
delay(300);
P0=0x7f;
P2=0x1f;
delay(300);
P2=0x8f;
delay(300);
P2=0xc7;
delay(300);
P2=0xe3;
delay(300);
P2=0xf1;
delay(300);
P2=0xf8;
delay(300);
}
//------------------------------------------------------------------
// CHUONG TRINH CHINH
//------------------------------------------------------------------
main()
{
while(1)
{
hieu_ung_1();
delay(300);
hieu_ung_2();
delay(300);
hieu_ung_3();
delay(300);
hieu_ung_4();
delay(300);
hieu_ung_5();
delay(300);
hieu_ung_5();
delay(300);
hieu_ung_6();
delay(300);
hieu_ung_6();
delay(300);
hieu_ung_7();
delay(300);
hieu_ung_8();
delay(300);
hieu_ung_9();
delay(300);
hieu_ung_10();
delay(300);
P0=P1=P2=P3=0x00;
hieu_ung_43();
delay(300);
hieu_ung_44();
delay(300);
hieu_ung_11();
delay(300);
hieu_ung_12();
delay(300);
hieu_ung_43();
delay(300);
hieu_ung_44();
delay(300);
hieu_ung_11();
delay(300);
hieu_ung_12();
delay(300);
hieu_ung_13();
delay(300);
hieu_ung_13();
delay(300);
hieu_ung_13();
delay(300);
hieu_ung_13();
delay(300);
hieu_ung_14();
delay(300);
hieu_ung_14();
delay(300);
hieu_ung_14();
delay(300);
hieu_ung_14();
delay(300);
hieu_ung_15();
delay(300);
hieu_ung_16();
delay(300);
hieu_ung_17();
delay(300);
hieu_ung_18();
delay(300);
hieu_ung_19();
delay(300);
hieu_ung_20();
delay(300);
hieu_ung_21();
delay(300);
hieu_ung_22();
delay(300);
hieu_ung_23();
delay(300);
hieu_ung_24();
delay(300);
hieu_ung_24();
delay(300);
hieu_ung_25();
delay(300);
hieu_ung_25();
delay(300);
hieu_ung_30();
delay(300);
hieu_ung_31();
delay(300);
hieu_ung_32();
delay(300);
hieu_ung_33();
delay(300);
hieu_ung_34();
delay(300);
hieu_ung_35();
delay(300);
hieu_ung_36();
delay(300);
hieu_ung_41();
delay(300);
hieu_ung_42();
delay(300);
hieu_ung_37();
delay(300);
hieu_ung_38();
delay(300);
P0=P1=P2=P3=0x00;
hieu_ung_43();
delay(300);
hieu_ung_44();
delay(300);
hieu_ung_43();
delay(300);
hieu_ung_44();
delay(300);
hieu_ung_37();
delay(300);
hieu_ung_39();
delay(300);
hieu_ung_38();
delay(300);
hieu_ung_40();
delay(300);
hieu_ung_11();
delay(300);
hieu_ung_12();
delay(300);
hieu_ung_30();
delay(300);
hieu_ung_25();
delay(300);
hieu_ung_24();
delay(300);
hieu_ung_23();
delay(300);
hieu_ung_22();
delay(300);
hieu_ung_21();
delay(300);
hieu_ung_15();
delay(300);
hieu_ung_26();
delay(300);
hieu_ung_16();
delay(300);
hieu_ung_27();
delay(300);
hieu_ung_17();
delay(300);
hieu_ung_28();
delay(300);
hieu_ung_18();
delay(300);
hieu_ung_45();
delay(300);
hieu_ung_19();
delay(300);
hieu_ung_20();
delay(300);
hieu_ung_29();
delay(300);
hieu_ung_37();
delay(300);
hieu_ung_39();
delay(300);
hieu_ung_38();
delay(300);
hieu_ung_40();
delay(300);
hieu_ung_30();
delay(300);
hieu_ung_11();
delay(300);
hieu_ung_12();
delay(300);
hieu_ung_43();
delay(300);
hieu_ung_44();
delay(300);
}
}
Không có nhận xét nào:
Đăng nhận xét