📄 text1.c
字号:
#include"reg52.h"
#define uchar unsigned char
#define uint unsigned int
#define N1 8
#define N2 9
uchar code led_3[]={0x00,0x81,0x42,0x24,0x18,0x24,0x42,0x81,0x00};
uchar code led_4[]={0xff,0x7e,0x3c,0x18,0x00,0x18,0x3c,0x7e,0xff};
uchar code led_5[]={0x80,0xa0,0xa8,0xaa,0x40,0x50,0x54,0x55};
uchar code led_6[]={0xff,0xfe,0xef,0x2f,0xf2,0x1f,0xf1,0x0f,0xf0};
uchar code led_7[]={0x00,0x01,0x10,0x03,0x30,0x07,0x70,0x0f,0xf0};
uchar code led_8[]={0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
void delay(uint tim)
{
for(;tim>0;tim--)
{};
}
void Cha_1()
{ uchar i,tt;
tt=0x00;
P1=tt;
tt=0x01;
for(i=0;i<8;i++)
{
P1=tt;
tt=tt<<1;
delay(1000);
}
}
void Cha_2()
{ uchar i,mm;
mm=0xff;
P1=mm;
for(i=0;i<8;i++)
{
P1=mm;
mm=mm>>1;
delay(1000);
}
}
void Cha_3()
{
uchar i,kk;
kk=0xff;
P1=kk;
for(i=0;i<8;i++)
{
P1=led_3[i];
delay(1000);
}
}
void cha_4(uchar num,uchar ligt)
{
uchar i;
for(i=0;i<num;i++)
{
P1=ligt;
delay(100);
}
}
void main()
{ uchar jj;
P1=0xff;
delay(2000);
P1=0x00;
while(1)
{
Cha_1();
delay(2000);
Cha_2();
delay(2000);
Cha_3();
delay(2000);
for(jj=0;jj<N1;jj++)
{
cha_4(N1,led_3[jj]);
}
for(jj=0;jj<N2;jj++)
{
cha_4(N2,led_4[jj]);
}
for(jj=0;jj<N1;jj++)
{
cha_4(N1,led_5[jj]);
}
for(jj=0;jj<N2;jj++)
{
cha_4(N2,led_6[jj]);
}
for(jj=0;jj<N2;jj++)
{
cha_4(N2,led_7[jj]);
}
for(jj=0;jj<N2;jj++)
{
cha_4(N2,led_8[jj]);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -