高分: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--)
{ 展开
#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--)
{ 展开
6个回答
展开全部
主函数呢?
追问
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;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询