找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

请教:单片机多路控制,每路定时15分钟灯闪烁

[复制链接]
admin 发表于 2012-9-2 07:56:36 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我刚学单片机,八路单独控制,就是不行
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char



void delay (uchar x)
{
uchar i,j; //?¨ò?2???T·?o???Dí±?á??£
for(i=x;i>0;i--) //í¨1yèí·?1?2ìμ??a
for(j=100;j>0;j--); //′?′|?óê±1S
}
void main()
{
P0 = 0xff; // à-??P0£?×?±??óê?ê?è?
P1 = 0x00; // P1??è??aè?0
P2 = 0x00; // P2??è??aè?0

while(1)
{switch(P0)
{case 1 : {P0=0xfe;P1=0x01;
delay(2000);
while(1)
{P1=0x01;
delay(500) ;
P1=0x00;
delay(500) ;
} ;
break;}
case 2 : {P0=0xfd;P1=0x02;
delay(1000);
while(1)
{P1=0x02;
delay(500);
P1=0x00;
delay(100) ;
} ;
break;}
case 3 : {P0=0xfb;P1=0x04;
delay(1000);
while(1)
{P1=0x04;
delay(100);
P1=0x00;
delay(100) ;
};
break;}
case 4: {P0=0xf7;P1=0x08;
delay(1000);
while(1)
{P1=0x08;
delay(100);
P1=0x00;
delay(100);
} ;
break;}
case 0xef: {P1=0x10;
delay(1000);
while(1)
{P1=0x10;;
delay(100);
P1=0x00;
delay(100);
};
break;}
case 0xea: {P1=0x20;
delay(1000);
while(1)
{ P1=0x20;
delay(100);
P1=0;
delay(100);
} ;
break;}
case 0xbf: {P1=0x40;
delay(1000);
while(P1)
{P1=0x40;
delay(100);
P1=0x00;
delay(100);
};
break;}
case 0x7f: {P1=0x80;
delay(1000);
while(1)
{P1=0x80;
delay(100);
P1=0x00;
delay(100);
};
break;}
default: {
P1=0x00;
}
}
}
}
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 08:00 , Processed in 0.054413 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表