美文网首页
普中科技51开发板

普中科技51开发板

作者: Hamiltonian | 来源:发表于2023-06-02 09:16 被阅读0次

按一下按钮1 LED灯常亮
按一下按钮2 LED灯熄灭

#include "reg52.h"

typedef unsigned int u16;   
typedef unsigned char u8;

sbit KEY1=P3^1;
sbit KEY2=P3^0;

sbit LED1=P2^0;

static int ledStatus = 0;

int pressStatus = 0;

void delay(unsigned int ms){
    ms = ms * 100;
    while(ms--);
}


void main(){
     while(1){
         if(KEY1 == 0){
             delay(10);
             if(KEY1 ==0){
                 LED1 = 0;
             }
         }
         if(KEY2 == 0){
             delay(10);
             if(KEY2 ==0){
                 LED1 = 1;
             }
         }
     }
}

相关文章

网友评论

      本文标题:普中科技51开发板

      本文链接:https://www.haomeiwen.com/subject/zcwpedtx.html