高分:89C51单片机流水灯程序求步骤详解,看懂了就给分

#include<reg51.h>#include<intrins.h>#defineucharunsignedchar#defineuintunsignedintuch... #include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code display_P0[]={
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF,
0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE, //
0xFC,0xF9,0xF3,0xE7,0xCF,0x9F,0x3F,0x7F,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //
0xE7,0xDB,0xBD,0x7E,0xBD,0xDB,0xE7,0xFF,
0xE7,0xC3,0x81,0x00,0x81,0xC3,0xE7,0xFF,
0xAA,0x55,0x18,0xFF,0xF0,0x0F,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0xFF };
uchar code display_P2[]={
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,
0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00, //
0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,
0xFC,0xF9,0xF3,0xE7,0xCF,0x9F,0x3F,0xFF, //
0xE7,0xDB,0xBD,0x7E,0xBD,0xDB,0xE7,0xFF,
0xE7,0xC3,0x81,0x00,0x81,0xC3,0xE7,0xFF,
0xAA,0x55,0x18,0xFF,0xF0,0x0F,0x00,0xFF,
0xFF,0x00,0x00,0xFF,0xFF };
/**********************************************************/
void delayms(uint ms)
// 延时子程序
{
uchar k;
while(ms--)
{
展开
 我来答
百度网友cf32d6b
2011-05-17
知道答主
回答量:16
采纳率:0%
帮助的人:13.5万
展开全部
主函数呢?
追问
void main(void)
{
uchar i;
P0 = 0xff;
P2 = 0xff;

while(1)
for(i=0;i <110; i++)
{
P0 =display_P0[i];
P2 =display_P2[i];
delayms(200);
}
}
追答
建议你别这么玩...写流水灯不用这么复杂吧
void main(void)
{
uchar i;
P0 = 0xff;
P2 = 0xff;
这几句的意思是主函数 P0 P2都至成1;
while(1) //这个应该不用写
for(i=0;i
#include

/*****************************************************************************
* 延时子程序 *
* *
******************************************************************************/
void delayms(unsigned char ms)
{
unsigned char i;
while(ms--)
{
for(i = 0; i < 120; i++);
}
}

/*****************************************************************************
* 主程序 *
* *
******************************************************************************/
main()
{
unsigned char LED;
LED = 0xfe;
P2 = LED;
while(1)
{
delayms(250);
LED = _crol_(LED,1); //循环右移1位,点亮下一个LED 此函数位库函数
P2 = LED;
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式