Altium Designer画的原理图和PCB图如下:(51hei附件中可下载工程文件)
单片机源程序如下:
- #include "key.h"
- #include "led.h"
- #include "ds18b20.h"
- #include "delay.h"
- #include "usart.h"
- #include "pwm.h"
- #include "LCD1602.h"
- #include "mode.h"
- /*****主函数*****/
- extern u8 char_value;
- extern short tem;
- u16 PWM_value;
- u8 key_value;
- int main(void)
- {
- u8 mode_flag = 0;
- PWM_value =SPEED0;
- short temp = 10;
- delay_init(72);
- Led_Init();//LED初始化
- Key_Init();
- Pwm_Init();
- Usart1_Init(72,9600);
- LCD_Init();
- while(DS18B20_Init())
- {
- LCD1602_DisString(0, 0, (u8*)"DS10B20 Err");
- }
- delay_ms(2000);
- LCD1602_Clear();
- LCD1602_DisString(0, 0, (u8*)"Tem: ");
- LCD1602_DisTemChar(6, 0);
- LCD1602_DisString(9, 0, (u8*)"Speed:0");
- LCD1602_DisString(0, 1, (u8*)"mode: ");
- while(1)
- {
- key_value = Key_Scan(0);
- tem = DS18B20_Get_Temp();
- LCD1602_DisTem(4, 0);
- delay_ms(50);
- if((key_value == 4 || char_value == '4')&&mode_flag==0)
- {
- mode_flag = 1;
-
- }
- else if((key_value == 4 || char_value == '4')&&mode_flag==1)
- {
- mode_flag = 0;
- char_value = 10;
- key_value = 0;
- }
- if(mode_flag) Auto_Mode();
- else Hand_Mode();
-
- TIM3 ->CCR2 = PWM_value;
- char_value = 10;
- key_value = 0;
- }
- }
复制代码
全部资料51hei下载地址:
基于STM32的智能蓝牙温控风扇.7z
(707.2 KB, 下载次数: 122)
|