標(biāo)題: 求思路 在單片機(jī)P1口連接8個(gè)發(fā)光二極管P3.0連接按鍵當(dāng)按鍵按下時(shí), [打印本頁]

作者: 晴天娃娃1號(hào)    時(shí)間: 2020-10-10 09:34
標(biāo)題: 求思路 在單片機(jī)P1口連接8個(gè)發(fā)光二極管P3.0連接按鍵當(dāng)按鍵按下時(shí),
在單片機(jī)P1口連接8個(gè)發(fā)光二極管P3.0連接按鍵當(dāng)按鍵按下時(shí),從低位到高位閃亮,按鍵合上反方向閃亮
求C語音程序的編寫思路

作者: 晴天娃娃1號(hào)    時(shí)間: 2020-10-11 18:43
#include<reg52.h>
#include<intrins.h>
#define  uchar unsigned char
#define uint unsigned int

sbit key=P3^0;

delay_ms(uint ms)
{    uint i,j;    for(i=ms;i>0;i--);      
for(j=114;j>0;j--);            
return 0; }

void main() {   
uint a,count=0;    a=0xfe;   

while(1)   
{    P1=a;    {    if(key==1)    {a=_crol_(a,1);   
delay_ms(500);       count++;}        
else                 
{         for(;count>0;count--)                 
{                 a=_cror_(a,1);                 P1=a;                 delay_ms(500);                                  }               

break;                 }         }   }   }




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1