45 lines
849 B
C
45 lines
849 B
C
#include "stm32f10x.h" // Device header
|
|
#include "Delay.h"
|
|
#include "LED.h"
|
|
#include "Key.h"
|
|
#include "Buzzer.h"
|
|
#include "Lightsensor.h"
|
|
|
|
int main(void)
|
|
{
|
|
Buzzer_Init();
|
|
LightSensor_Init();
|
|
|
|
while(1)
|
|
{
|
|
if( GPIOB_LightSensor_Get(GPIO_Pin_13) == 1 )
|
|
GPIOB_Buzzer(GPIO_Pin_12,high);
|
|
else
|
|
GPIOB_Buzzer(GPIO_Pin_12,low);
|
|
|
|
|
|
/*
|
|
GPIOA_LED(GPIO_Pin_1,low);
|
|
Delay_ms(500);
|
|
GPIOA_LED(GPIO_Pin_1,high);
|
|
GPIOA_LED(GPIO_Pin_2,low);
|
|
Delay_ms(500);
|
|
GPIOA_LED(GPIO_Pin_2,high);
|
|
*/
|
|
|
|
|
|
//蜂鸣器工作
|
|
/*
|
|
GPIO_ResetBits(GPIOB,GPIO_Pin_12);//低电平响
|
|
Delay_ms(100);
|
|
GPIO_SetBits(GPIOB,GPIO_Pin_12);//高电平不响
|
|
Delay_ms(100);
|
|
GPIO_ResetBits(GPIOB,GPIO_Pin_12);
|
|
Delay_ms(100);
|
|
GPIO_SetBits(GPIOB,GPIO_Pin_12);
|
|
Delay_ms(700);
|
|
*/
|
|
}
|
|
}
|
|
|