爱心流水灯程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
sbit p0_6=P0^5;
sbit p0_7=P0^6;
sbit p0_8=P0^7;
sbit p1_1=P1^0;
sbit p1_2=P1^1;
sbit p1_3=P1^2;
sbit p1_4=P1^3;
sbit p1_5=P1^4;
sbit p1_6=P1^5;
sbit p1_7=P1^6;
delay(50);
p1_2=0;
delay(50);
p1_3=0;
delay(50);
p1_4=0;
delay(50);
p1_5=0;
delay(50);
p1_6=0;
delay(50);
p1_7=0;
delay(50);
p1_8=0;
delay(50);
p3_1=0;
delay(50);
p3_2=0;
P1=s;
delay(50);
}
P1=0xff;
temp3=0x01;
P3=temp3;
delay(50);
for(k=0;k<8;k++)
{
s=temp3<<1;
P3=s;
delay(50);
}
P3=0xff;
temp2=0x01;
P2=temp2;
delay(50);
for(k=0;k<8;k++)
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
delay(200);
P0=0xf0;
delay(20);
P0=0x00;
delay(20);
p0_3=1;
delay(50);
p0_4=1;
delay(50);
p0_5=1;
delay(50);
p0_6=1;
delay(50);
p0_7=1;
delay(50);
p0_8=1;
delay(50);
p2_8=1;
delay(50);
p2_7=1;
delay(50);
p2_6=1;
delay(50);
#include<reg52.h>
#include<intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit p0_1=P0^0;
sbit p0_2=P0^1;
sbit p0_3=P0^2;
sbit p0_4=P0^3;
sbit p0_5=P0^4;
sbit p1_8=P1^7;
sbit p2_1=P2^0;
sbit p2_2=P2^1;
sbit p2_3=P2^2;
sbit p2_4=P2^3;
sbit p2_5=P2^4;
sbit p2_6=P2^5;
sbit p2_7=P2^6;
sbit p2_8=P2^7;
sbit p3_1=P3^0;
delay(50);
p3_7=0;
delay(50);
p3_6=0;
delay(50);
p3_5=0;
delay(50);
p3_4=0;
delay(50);
p3_3=0;
delay(50);
p3_2=0;
delay(50);
p3_1=0;
delay(50);
p1_8=0;
delay(50);
p1_7=0;
delay(50);
p1_6=0;
delay(50);
p1_5=0;
delay(50);
p1_4=0;
delay(50);
p1_3=0;
delay(50);
p1_2=0;
delay(50);
p1_1=0;
delay(50);
/*......*/
p0_1=1;
delay(50);
p0_2=1;
delay(50);
p2_1=0;
delay(50);
/*......*/
p2_1=1;
delay(50);
p3_8=1;
p2_2=1;
delay(35);
p3_7=1;
p2_3=1;
delay(50);
p3_6=1;
p2_4=1;
delay(50);
p3_5=1;
p2_5=1;
delay(50);
p3_4=1;
p2_6=1;
delay(50);
p2_4=0;
delay(50);
p2_5=0;
delay(50);
p2_6=0;
delay(50);
p2_7=0;
delay(50);
p2_8=0;
delay(50);
p0_8=0;
delay(50);
p0_7=0;
delay(50);
p0_6=0;
delay(50);
p0_5=0;
delay(50);
p0_4=0;
delay(50);
p0_3=0;
delay(50);
p0_2=0;
delay(50);
p0_1=0;
delay(50);
/*......*/
p1_1=1;
delay(50);
p1_2=1;
delay(50);
p1_3=1;
delay(50);
p1_4=1;
delay(50);
P2=0x00;
P3=0x00;
delay(400);
for(k=0;k<4;k++)
{
P0=0x00;
P1=0x00;
P2=0x00;
P3=0x00;
delay(200);
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
delay(200);
}
for(k=0;k<72;k++)
{
P0=0x55;
p3_4=1;
delay(50);
p3_3=1;
delay(50);
p3_2=1;
delay(50);
p3_1=1;
delay(50);
p1_8=1;
delay(50);
p1_7=1;
delay(50);
p1_6=1;
delay(50);
p1_5=1;
delay(50);
p1_4=1;
delay(50);
delay(35);
p3_3=1;
p2_7=1;
delay(50);
p3_2=1;
p2_8=1;
delay(50);
p3_1=1;
p0_8=1;
delay(35);
p1_8=1;
p0_7=1;
delay(50);
p1_7=1;
p0_6=1;
delay(50);
p1_6=1;
p0_5=1;
delay(50);
p0_3=0;
delay(40);
p1_5=0;
p0_4=0;
delay(50);
p1_6=0;
p0_5=0;
delay(50);
p1_7=0;
p0_6=0;
delay(50);
p1_8=0;
p0_7=0;
delay(50);
p3_1=0;
p0_8=0;
delay(50);
p3_2=0;
p2_8=0;
uchar temp3;
uint k,s;
void delay(uint j)
{
uint i;
for(j;j>0;j--)
for(i=120;i>0;i--);
}
void main()
{
while(1)
{
for(k=0;k<4;k++)
{
P0=0x00;
P1=0x00;
P2=0x00;
P3=0x00;
P1=0x55;
P2=0x55;
P3=0x55;
delay(100);
P0=0xaa;
P1=0xaa;
P2=0xaa;
P3=0xaa;
delay(100);
}
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
delay(500);
/*.......*/
for(k=0;k<4;k++)
{
p3_6=1;
delay(50);
p3_7=1;
delay(50);
p3_8=1;
delay(50);
p2_1=1;
delay(50);
p2_2=1;
delay(50);
p2_3=1;
delay(50);
p2_4=1;
delay(50);
p2_5=1;
delay(50);
p2_6=1;
delay(50);
delay(500);
P0=0xff;
P1=0xff;
P2=0xff;
P3=0xff;
delay(500);
}
for(k=0;k<7;k++)
{
temp0=0x01;
P0=temp0;
delay(100);
for(k=0;k<8;k++)
{
s=temp0<<1;
P0=s;
delay(50);
}
P0=0xff;
delay(50);
p3_3=0;
p2_7=0;
delay(50);
p3_4=0;
p2_6=0;
delay(50);
p3_5=0;
p2_5=0;
delay(50);
p3_6=0;
p2_4=0;
delay(50);
p3_7=0;
p2_3=0;
delay(50);
p3_8=0;
p2_2=0;
delay(50);
p2_7=1;
delay(50);
p2_8=1;
delay(50);
p0_8=1;
delay(50);
p0_7=1;
delay(50);
p0_6=1;
delay(50);
p0_5=1;
delay(50);
p0_4=1;
delay(50);
p0_3=1;
delay(50);
p0_2=1;
delay(50);
p1_5=1;
delay(50);
p1_6=1;
delay(50);
p1_7=1;
delay(50);
p1_8=1;
delay(50);
p3_1=1;
delay(50);
p3_2=1;
delay(50);
p3_3=1;
delay(50);
p3_4=1;
delay(50);
p3_5=1;
delay(50);
p1_5=1;
p0_4=1;
delay(50);
p1_4=1;
p0_3=1;
delay(50);
p1_3=1;
p0_2=1;
delay(50);
p1_2=1;
p0_1=1;
delay(50);
p1_1=1;
delay(50);
}
}
/***********/
delay(400);
P0=0x00;
P1=0x00;
temp2=0x01;
P2=temp0;
delay(100);
for(k=0;k<8;k++)
{
s=temp2<<1;
P2=s;
delay(50);
}
P2=0xff;
temp3=0x01;
P3=temp0;
delay(100);
for(k=0;k<8;k++)
{
s=temp3<<1;
P3=s;
delay(50);
p0_1=1;
delay(50);
/*......*/
p0_1=0;
delay(50);
p0_2=0;
delay(50);
p0_3=0;
delay(50);
p0_4=0;
delay(50);
p0_5=0;
delay(50);
p0_6=0;
delay(50);
p0_7=0;
delay(50);
p0_8=0;
}
P3=0xff;
temp1=0x01;
P1=temp0;
delay(100);
for(k=0;k<8;k++)
{
s=temp1<<1;
P1=s;
delay(50);
}
delay(500);
temp1=0x01;
P1=temp1;
delay(100);
for(k=0;k<7;k++)
{
s=temp1>>1;
sbit p3_2=P3^1;
sbit p3_3=P3^2;
sbit p3_4=P3^3;
sbit p3_5=P3^4;
sbit p3_6=P3^5;
sbit p3_7=P3^6;
sbit p3_8=P3^7;
void delay(uint);
uchar temp0;
uchar temp1;
uchar temp2;
delay(50);
p2_8=0;
delay(50);
p2_7=0;
delay(50);
p2_6=0;
delay(50);
p2_5=0;
delay(50);
p2_4Байду номын сангаас0;
delay(50);
p2_3=0;
delay(50);
p2_2=0;
delay(50);
p2_1=0;
delay(50);
p3_8=0;
delay(50);
p3_3=0;
delay(50);
p3_4=0;
delay(50);
p3_5=0;
delay(50);
p3_6=0;
delay(50);
p3_7=0;
delay(50);
p3_8=0;
delay(50);
p2_1=0;
delay(50);
p2_2=0;
delay(50);
p2_3=0;
p1_3=1;
delay(50);
p1_2=1;
delay(1);
p1_1=1;
delay(50);
/*..........*/
for(k=0;k<3;k++)
{
p1_1=0;
delay(50);
p1_2=0;
p0_1=0;
delay(50);
p1_3=0;
p0_2=0;
delay(50);
p1_4=0;
{
s=temp2<<1;
P2=s;
delay(50);
}
P2=0xff;
temp0=0x01;
P0=temp0;
delay(50);
for(k=0;k<8;k++)
{
s=temp0>>1;
P0=s;
delay(50);
}
P0=0xff;
}
delay(1000);
for(k=0;k<2;k++)
{
p1_1=0;
p2_5=1;
delay(50);
p2_4=1;
delay(50);
p2_3=1;
delay(50);
p2_2=1;
delay(50);
p2_1=1;
delay(50);
p3_8=1;
delay(50);
p3_7=1;
delay(50);
p3_6=1;
delay(50);
p3_5=1;
delay(50);
相关文档
最新文档