Upload files to "3-5 GPIO_光敏传感器/User"
This commit is contained in:
44
3-5 GPIO_光敏传感器/User/main.c
Normal file
44
3-5 GPIO_光敏传感器/User/main.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#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);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user