標(biāo)題: 單片機(jī)p0口輸出下降波程序 [打印本頁]

作者: xiongda    時(shí)間: 2015-5-26 19:12
標(biāo)題: 單片機(jī)p0口輸出下降波程序
#include<reg51.h>

#define uchar unsigned char
#define uint unsigned int
#define dadata P0


void delay(uint xms)
{
        uint i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);

}

void main()
{
        uchar temp=255,a=1;
        while(1)
        {
       
                 if(a==0)
                {
                         dadata=temp        ;
                        delay(5);
                        temp--;
                        if(temp==255)
                        a=1;
                          

                }
                                 
                if(a==1)
                {
                         dadata=temp;
                        delay(5);
                        temp--;
                        if(temp==0)
                        a=0;

                }
                          


        }



}



作者: wujunbo27    時(shí)間: 2015-5-27 01:56





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