#include “stm32f10x.h”
#include “Delay.h”
#include “LED.h”
#include “Key.h”
uint8_t KeyNum;
int main(void)
{
LED_Init();
Key_Init();
while (1) { KeyNum=Key_GetNum(); //不断读取键码 if(KeyNum==1) //按键1被按下 { LED1_ON(); } if(KeyNum==2) //按键2被按下 { LED1_OFF(); } }}
要实现按下熄灭,再按一下点亮
#include “stm32f10x.h”
#include “Delay.h”
#include “LED.h”
#include “Key.h”
uint8_t KeyNum;
int main(void)
{
LED_Init();
Key_Init();
while (1) { KeyNum=Key_GetNum(); //不断读取键码 if(KeyNum==1) //按键1被按下 { LED1_Turn(); } if(KeyNum==2) //按键2被按下 { LED2_Turn(); } }}