本项目聚焦于使用STM32F系列微控制器结合光敏电阻传感器开发光照强度监测系统,探讨硬件电路设计及软件编程技巧。
```c
#include sys.h
#include delay.h
#include usart.h
#include led.h
#include lcd.h
#include adc3.h
#include lsens.h
// ALIENTEK 探索者STM32F407开发板 实验18 光敏传感器实验-库函数版本
int main(void) {
u8 adcx;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); // 设置系统中断优先级分组为2
delay_init(168); // 初始化延时函数
uart_init(115200); // 初始化串口波特率为115200
LED_Init(); // 初始化LED
LCD_Init(); // 初始化LCD
Lsens_Init(); // 初始化光敏传感器
POINT_COLOR = RED; // 设置字体为红色
LCD_ShowString(30, 50, 200, 16, 16, Explorer STM32F4);
LCD_ShowString(30, 70, 200, 16, 16, LSENS TEST);
LCD_ShowString(30, 90, 200, 16, 16, ATOM@ALIENTEK);
LCD_ShowString(30, 110, 200, 16, 16, 2014/5/7);
POINT_COLOR = BLUE; // 设置字体为蓝色
LCD_ShowString(30, 130, 200, 16, 16, LSENS_VAL:);
while (1) {
adcx = Lsens_Get_Val();
LCD_ShowxNum(30 + 10 * 8, 130, adcx, 3, 16, 0); // 显示ADC的值
LED0 = !LED0;
delay_ms(250);
printf(im ok);
}
}
```