单片机楼梯灯制作(C语言版)

//51单片机

//p3.5口接灯的阴极端,按键划分接p2.0 p2.1

#include

#define uchar unsigned char

#define uint unsigned int

#define LED_ON 0

#define LED_OFF 1

sbit led = P3^5;

sbit key_up = P2^0;

sbit key_down = P2^1;

void main(void)

{

  key_up = 1;

  key_down = 1;

  led = 1;

  while(1)

  {

       if(key_down)

{

     if(key_up)

         {

              led = LED_OFF;

         }

         else

         {

              led = LED_ON;

         }

}

else

{

     if(key_up)

 {

      led = LED_ON;

 }

 else

 {

      led = LED_OFF;

 }

}   

  }

}

以上是单片机楼梯灯制作(C语言版)的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>