光敏电阻控制蜂鸣器

This commit is contained in:
2026-08-11 23:41:24 +08:00
parent beea93edb8
commit ded38a7c44
6 changed files with 77 additions and 15 deletions

View File

@@ -1,22 +1,17 @@
#include "stm32f10x.h"
#include "Delay.h"
#include "LED.h"
#include "Key.h"
#include "Buzzer.h"
#include "LightSensor.h"
uint8_t KeyNum;
int main(void){
LED_Init();
Key_Init();
while(1){
KeyNum = Key_GetNum();
if (KeyNum == 1) {
LED0_TOGGLE();
int main(void) {
Buzzer_Init();
LightSensor_Init();
while (1) {
if (LightSensor_Read() == 1) {
Buzzer_ON();
} else {
Buzzer_OFF();
}
if (KeyNum == 2) {
LED1_TOGGLE();
}
}
}