標(biāo)題: 基于51 單片機(jī)的簡(jiǎn)單時(shí)鐘程序 [打印本頁(yè)]

作者: 302908660    時(shí)間: 2020-1-3 10:31
標(biāo)題: 基于51 單片機(jī)的簡(jiǎn)單時(shí)鐘程序
#include <REGX51.H>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uint a,j,num,temp;
uchar b;
void inition();
void main()
{
        inition();
        b=0X01;
        while(1)
        {
                if(num==10)
                {
                        num=0;
               
                        P1=~b;
                        b=b<<1;
                        if(b==0x00)
                        b=0x01;
                }
        }
}
void time0() interrupt 1
{
        TH0=(65535-50000)/256;
        TL0=(65535-50000)%256;
        num++;
}
void inition()
{
        EA=1;
        ET0=1;
        TMOD=0X01;
        TH0=(65535-50000)/256;
        TL0=(65535-50000)%256;
        TR0=1;
}






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