亿加合和智能车制作

标题: 单片机流水灯求解 [打印本页]

作者: 我唯一的小倩    时间: 2018-7-22 14:58
标题: 单片机流水灯求解
#include<reg52.h>
#include<intrins.h>
#define led P2
#define  uint unsigned int
#define  uchar unsigned char
void delay(uint) ;
uchar aa ;
uint i,j,x;
void main()
{
led=0xfe;
delay(200);
   while(1)
   { for(x=0;x<7;x++)
   {  led=_crol_(led,1)  ;
          delay(200);
   }
    for(x=0;x<7;x++)
   {   led=_cror_(led,1)  ;
          delay(200);
   }
   }
}
void delay(uint xms)
{
for (i=xms;i>0;i--)
for (j=110;j>0;j--)  ;
}
为啥流水灯左右移必须用到#define led P2这条语句;用这个程序是错的??????
#include<reg52.h>
#include<intrins.h>
#define  uint unsigned int
#define  uchar unsigned char
void delay(uint) ;
uchar aa ;
uint i,j,x;
void main()
{
   aa=0xfe;
   P2=aa;
   delay(500);
   while(1)
   { for(x=0;x>7;x--)
   {   P2=_crol_(aa,1)  ;
          delay(500);
   }
    for(x=0;x>7;x--)
   {   P2=_cror_(aa,1)  ;
          delay(500);
   }
   }
}
void delay(uint xms)
{
for (i=xms;i>0;i--)
for (j=110;j>0;j--)  ;
}

作者: 神车名为GTR    时间: 2018-7-22 15:33
cror和crol是控制左移右移吧?
自己理一下思路吧……
建议写程序顺便把注释写上

作者: 快上车    时间: 2018-7-22 19:58
不把编译报错的内容发上来,让我们怎么分析
作者: 我唯一的小倩    时间: 2018-7-25 09:47
快上车 发表于 2018-7-22 19:58
不把编译报错的内容发上来,让我们怎么分析

编译没报错,但是第二个程序开发板led灯不亮

作者: 我唯一的小倩    时间: 2018-7-25 09:48
神车名为GTR 发表于 2018-7-22 15:33
cror和crol是控制左移右移吧?
自己理一下思路吧……
建议写程序顺便把注释写上

好的,知道了






欢迎光临 亿加合和智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2