高分: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--)
{
展开
 我来答
quan22911
2011-05-17 · TA获得超过327个赞
知道答主
回答量:194
采纳率:0%
帮助的人:104万
展开全部
  uchar code display_P0[]={
  0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F,//P0口由低位向高位依次亮灯(前一位的灯灭)
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,//P0口灯全灭
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,,//P0口灯全灭
  0x7F,0xBF,0xDF,0xEF,0xF7,0xFB,0xFD,0xFE,0xFF,//P0口由高位向低位依次亮灯(前一位的灯灭),最后全灭
  0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x80,0x00,//P0口由低位向高位依次亮灯(前一位的灯b不灭)
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //P0口灯全亮
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//P0口灯全亮
  0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE, //P0口灯由高位向低位依次灭(前一位不亮),最后仅剩最低位亮灯。
  0xFC,0xF9,0xF3,0xE7,0xCF,0x9F,0x3F,0x7F,//P0口以两个亮灯为单位,由低位向高位逐位移动,最后移至最高位,仅剩最高位亮灯。
  0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //P0口全灭
  0xE7,0xDB,0xBD,0x7E,0xBD,0xDB,0xE7,0xFF,//P0口中间两位亮灯,然后两个亮灯分别向两端移动,当分别移至最高位和最低位时,再按原方法返回,返回至起始状态后全灭。
  0xE7,0xC3,0x81,0x00,0x81,0xC3,0xE7,0xFF,//P0口中间两位亮灯,然后两个亮灯分别向两端扩散,当分别扩散至次高位和次低位时,再按原方法恢复,返回至起始状态后全灭。
  0xAA,0x55,0x18,0xFF,0xF0,0x0F,0x00,0xFF,//差位两灭,先是最高位亮,然后最高位灭;再变成中间两位灭,其余的全亮;全灭→低四位亮→高四位亮→全灭。
  0xFF,0x00,0x00,0xFF,0xFF };//全灭→全亮→全亮→全灭→全灭
  uchar code display_P2[]={ //P2口可参照P0口流水灯情况。基本相同。
  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 };
追问
太帅啦!再问下啊,这个是用软件延时的,它体现在哪,调用子程序体现在哪吗?可以回答分就给你啦,不行就给你60%的分,可以吧?这是主程序
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);
}
}
zhxiufan
推荐于2017-10-27 · 知道合伙人软件行家
zhxiufan
知道合伙人软件行家
采纳数:14923 获赞数:38387
国家科技进步奖

向TA提问 私信TA
展开全部
//这是一个花样流水灯控制程序,主程序没有,由数组值来控制
#include <reg51.h> //提供基本的51单片机端口定义
#include <intrins.h> //这个头文件主要提供移位控制函数
#define uchar unsigned char
#define uint unsigned int
uchar code display_P0[]={ //这个数组控制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[]={ //这个数组控制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--)
{
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
巨季雅d0
2011-05-17 · TA获得超过1365个赞
知道小有建树答主
回答量:1101
采纳率:0%
帮助的人:623万
展开全部
看不懂,
你这仅仅是一段数据
还有一个不完整的延时子函数
连个主函数也没有
没人能看懂,
但是我却明白你可能要表达的意思
其实,同学,你用这种查表方式实现的流水灯,程序结构不太好
我认为还是用循环,移位等办法

OK
追问
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);
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
seilliuwang
2011-05-17
知道答主
回答量:23
采纳率:0%
帮助的人:0
展开全部
没找到主函数~~ 数组里面写的是你想让跑马灯的跑法~~
追问
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);
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
huijianc
2011-05-17 · TA获得超过403个赞
知道小有建树答主
回答量:296
采纳率:0%
帮助的人:173万
展开全部
主函数呢?有意思
追问
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);
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(4)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式