标题: 流水灯c程序设计 求帮助 [打印本页]

作者: 小鸡快跑8090    时间: 2018-1-14 16:32
标题: 流水灯c程序设计 求帮助
(2)对整个口进行赋值操作,如P0= ~ 0x01; P0= ~ 0x02;  P0= ~ 0x04; 实现8位的LED流水灯。
例2:LED1:亮0.5S,暗0.5S—LED2:亮0.5S,暗0.5S。。。。。LED8:亮0.5S,暗0.5S—LED1:亮0.5S,暗0.5S—循环往复。

IMG_1269.PNG (72.47 KB, 下载次数: 28)

IMG_1269.PNG

作者: lhl139679    时间: 2018-1-14 17:49
#include <stdio.h>
作者: lhl139679    时间: 2018-1-14 18:35
#include <stdio.h>
int count = 0;
void main()
{
      
      P2 = 0xFF;
      TMOD = 0x01;
      TH0 =(-50000)/256 ;
      TL0 = (-50000)%256;
      ET0 = 1;
      EA = 1;
                        TR0 = 1;
      while(1);
}

void dingshiqi() interrupt 1
{
      TH0 =(-50000)/256;
      TL0 = (-50000)%256;
      count++;
      if(count == 10)
     {
         P2 = ~P2;
         count = 0;
     }
}




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1