E:\mach
trai tim\lap trinh\hepro.c
// project:mach led trai tim
// Design by leduche_dt3k3
// time:20:48/13/09/2009
// hotline:0979025040
// email:
//############################################
#include<reg52.h>
#include<stdio.h>
#include<intrins.h>
unsigned int i,j,k;
//###### ham delay tao thoi gian tre 0.5s ######
void delay(unsigned int ms)
{
unsigned int a;
unsigned char b;
for(a=0;a{
for(b=0;b<125;b++)
{
}
}
}
//##### hieu ung chop tat toan bo led ########
void hieu_ung_1(void)
{
for(k=0;k<8;k++)
{
P0=P1=P2=P3=0xff;
delay(300);
P0=P1=P2=P3=0x00;
delay(300);
}
}
//##### hieu ung chop 2 nua trai tim #########
void hieu_ung_2(void)
{
for(i=0;i<6;i++)
{
P0=P3=0x00;
delay(300);
P0=P3=0xff;
P1=P2=0x00;
delay(300);
P1=P2=0xff;
}
}
//##### hieu ung led nhay so le 1 ##############
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 led 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;
Page: 1
E:\mach
trai tim\lap trinh\hepro.c
delay(300);
}
}
//##### p0,p1,p2,p3,p4 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);
}
}
//##### p0,p1,p2,p3,p4 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 dan het cac led theo chieu 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=0xff;
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);
}
Page: 2
E:\mach
trai tim\lap trinh\hepro.c
}
//##### tat dan het cac led theo chieu 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=0x00;
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 dan het cac led theo chieu nghich #####
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=0xff;
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 dan het cac led theo chieu nghich #####
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=0x00;
for(i=0;i<8;i++)
{
P1=M[i];
delay(300);
}
for(i=0;i<8;i++)
Page: 3
E:\mach
trai tim\lap trinh\hepro.c
{
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 pro 1 #################
void hieu_ung_11(void)
{
unsigned char M[]={0xf0,0xe1,0xc3,0x87,0x0f};
unsigned char N[]={0x0f,0x4f,0x63,0x71,0x78};
unsigned char L[]={0x1f,0x4f,0x6f,0x73,0x79,0x7c};
unsigned char K[]={0x3f,0x5f,0x6f,0x77,0x7b,0x7d,0x7e};
P0=P1=P2=P3=0xff;
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 pro 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=0xff;
for(i=0;i<5;i++)
{
P1=M[i];
delay(300);
}
P1=0xff;
for(i=0;i<5;i++)
{
P3=N[i];
delay(300);
}
Page: 4
E:\mach
trai tim\lap trinh\hepro.c
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;
}
//##### tat het cac led pr0 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=0x00;
for(i=0;i<6;i++)
{
P3=P2=P1=N[i];
P0=M[i];
delay(300);
}
}
//##### tat het cac led pro 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=0x00;
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=0xff;
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 ##############
Page: 5
E:\mach
trai tim\lap trinh\hepro.c
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=0xff;
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};
Page: 6
E:\mach
trai tim\lap trinh\hepro.c
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,
Page: 7
E:\mach
trai tim\lap trinh\hepro.c
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)
Page: 8
E:\mach
trai tim\lap trinh\hepro.c
{
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];
Page: 9
E:\mach
trai tim\lap trinh\hepro.c
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++)
Page: 10
E:\mach
trai tim\lap trinh\hepro.c
{
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};
Page: 11
E:\mach
trai tim\lap trinh\hepro.c
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};
Page: 12
E:\mach
trai tim\lap trinh\hepro.c
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};
Page: 13
E:\mach
trai tim\lap trinh\hepro.c
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,
Page: 14
E:\mach
trai tim\lap trinh\hepro.c
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++)
{
Page: 15
E:\mach
trai tim\lap trinh\hepro.c
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);
Page: 16
E:\mach
trai tim\lap trinh\hepro.c
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);
Page: 17
E:\mach
trai tim\lap trinh\hepro.c
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);
Page: 18
E:\mach
trai tim\lap trinh\hepro.c
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);
Page: 19
E:\mach
trai tim\lap trinh\hepro.c
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);
}
}
Page: 20