回覆列表
  • 1 # 使用者7169188564904

    #include

    #define uchar unsigned char

    sbit LED=P1^0;

    uchar time;

    void initT0( )

    {

    TMOD = 0x01; //定時器0,工作方式1

    TH0 = (65536-50000)/256;

    TL0 = (65536-50000)%256; //50ms中斷一次

    EA = 1;

    ET0 = 1;

    TR0 = 1;

    }

    void main(void)

    {

    initT0();

    while(1)

    if(time==20) //中斷20次,1s

    {

    time=0;

    LED=!LED; //P1.0上的LED,1s亮或滅一次

    }

    }

    void T0int( ) interrupt 1

    {

    TH0 = (65536-65536)/256;

    TL0 = (65536-65536)%256;

    time++;

    }

  • 中秋節和大豐收的關聯?
  • 問道怎麼把3速的坐騎弄成5速怎麼弄啊求解答?