采用dht11溫濕度傳感器,和pm2.5傳感器,用tft液晶屏顯示
做出來(lái)的實(shí)物圖:
IMG_20171019_091028.jpg (4.56 MB, 下載次數(shù): 60)
下載附件
2017-10-20 21:49 上傳
IMG_20171019_091024.jpg (4.37 MB, 下載次數(shù): 33)
下載附件
2017-10-20 21:49 上傳
單片機(jī)源程序如下:
- #include "delay.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "led.h"
- #include "dht11.h"
- #include "ds18b20.h"
- #include "adc.h"
- unsigned char hjjc[72*6] = // ASCII
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xE7,0x1F,0x58,0x98,0x00,0x40,0x80,0x00,0x40,0x40,0x00,
- 0x40,0x40,0x00,0xC0,0xE3,0x00,0x78,0x60,0x00,0x40,0x50,0x02,0x40,0x50,0x04,0x40,0x48,0x08,0x40,0x46,0x10,0xC0,0x43,0x30,
- 0x30,0x42,0x20,0x8C,0x41,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"環(huán)",0*/
- …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0xC4,0x00,0x86,0x01,0x86,0x01,0x86,0x01,0x80,0x01,0xC0,0x00,
- 0x70,0x00,0x80,0x01,0x00,0x01,0x00,0x03,0x06,0x03,0x06,0x03,0x06,0x03,0x84,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"3",4*/
- };
- //ALIENTEK戰(zhàn)艦STM32開發(fā)板實(shí)驗(yàn)13
- //TFTLCD顯示實(shí)驗(yàn)
- //技術(shù)支持:www.openedv.com
- //廣州市星翼電子科技有限公司
- extern u8 Res;
- extern u8 Res3;
- int tcont,cont=5;;
- extern __IO u16 ADC_ConvertedValue[4];
- void numstring(uint16_t Xpos, uint16_t Ypos, u32 mun,u16 BL)
- {
- shuzi24(Xpos, Ypos, &ASCII_Table24N[0+48*(mun/10)], BL);
- shuzi24(Xpos+12*1, Ypos, &ASCII_Table24N[0+48*(mun%10)], BL);
-
- }
- void numstrings(uint16_t Xpos, uint16_t Ypos, u32 mun,u16 BL)
- {
- shuzi24(Xpos, Ypos, &ASCII_Table24N[0+48*(mun/1000)], BL);
- shuzi24(Xpos+12*1, Ypos, &ASCII_Table24N[0+48*(mun%1000/100)], BL);
- shuzi24(Xpos+12*2, Ypos, &ASCII_Table24N[0+48*(mun%1000%100/10)], BL);
- shuzi24(Xpos+12*3, Ypos, &ASCII_Table24N[0+48*(mun%1000%100%10)], BL);
-
- }
- void zifuchar(uint16_t Xpos, uint16_t Ypos, u8 * mun,u16 BL)
- {
- shuzi24(Xpos, Ypos, mun, BL);
- shuzi24(Xpos+12*1, Ypos, mun+48*1, BL);
- shuzi24(Xpos+12*2, Ypos, mun+48*2, BL);
- shuzi24(Xpos+12*3, Ypos, mun+48*3, BL);
- shuzi24(Xpos+12*4, Ypos, mun+48*4, BL);
-
- }
- int main(void)
- {
- u8 humidity;
- u8 temp;
- short temperature;
- delay_init(); //延時(shí)函數(shù)初始化
- NVIC_Configuration(); //設(shè)置NVIC中斷分組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
- uart_init(115200); //串口初始化為9600
- LED_Init();
- Adc_Init(); //adc8
- // USART3_Config();
- LCD_Init();
- POINT_COLOR=RED;
- wordstring(40, 10,hjjc,6,RED); //環(huán)境監(jiān)測(cè)系統(tǒng)
- wordstring(10, 150,wd,2,RED); //溫度
- wordstring(10, 180,sd,2,RED); // 濕度
- while(DS18B20_Init());
- while(1)
- {
- temperature=DS18B20_Get_Temp();
- if(temperature<0)
- {
- shuzi24(55, 150, fh, RED); //顯示負(fù)號(hào)
- temperature=-temperature; //轉(zhuǎn)為正數(shù)
- }else shuzi24(55, 150, qk, RED); //去掉負(fù)號(hào)
- //
- DHT11_Read_Data(&temp,&humidity); //讀取溫濕度值
- numstring(70, 150,temperature/10,BRED); //顯示溫度
- wordstring(100, 150,wd+72*2,1,RED); //溫度符號(hào)
- numstring(70, 180,humidity,BRED); //顯示濕度
- shuzi24(100, 180,sdfh,RED);shuzi24(112, 180,sdfh+48,RED);shuzi24(124, 180,sdfh+96,RED); //濕度符號(hào)
- zifuchar(5, 210,PM,RED);
- shuzi24(70, 210,&ASCII_Table24N[0+48*(Get_Adc_Average(1)/620)], BRED); //毫克量
- zifuchar(90, 210,MG,RED);
- delay_ms(200);
- }
- }
- /*代碼說(shuō)明*/
- /*main函數(shù)掃描按鍵顯示放電預(yù)設(shè)值
- * 定時(shí)器3 放電定時(shí)
- * 定時(shí)器4 ad掃描
- */
復(fù)制代碼
所有資料51hei提供下載:
課設(shè)環(huán)境監(jiān)測(cè)系統(tǒng).rar
(368.26 KB, 下載次數(shù): 324)
2017-10-21 02:42 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
|