找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2496|回復(fù): 0
收起左側(cè)

單片機車廂檢測+上位機串口通訊仿真(Proteus仿真+源碼)

[復(fù)制鏈接]
ID:916329 發(fā)表于 2021-5-22 11:13 | 顯示全部樓層 |閱讀模式
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
51hei.png
51hei截圖20210522111303.png

部分源碼
  1. #include "reg51.h"
  2. #include "intrins.h"
  3. #include "dht11.c"
  4. #include "adc.c"
  5. #include "key.c"
  6. #include "lcd1602.c"
  7. #include "UART.c"

  8. sbit LED0 = P2^3;
  9. sbit LED1 = P2^4;
  10. sbit LED2 = P2^5;
  11. sbit Buzzer = P2^6;


  12. void judge()
  13. {
  14.         if(humi_value < rh_low || humi_value > rh_high)
  15.         {
  16.                 LED0 = 0;
  17.         }
  18.         else
  19.                 LED0 = 1;
  20.         if(temp_value < temp_low || temp_value > temp_high)
  21.         {
  22.                 LED1 = 0;
  23.         }
  24.         else
  25.                 LED1 = 1;
  26.         if(co2 < co2_low || co2 > co2_high)
  27.         {
  28.                 LED2 = 0;
  29.         }
  30.         else
  31.                 LED2 = 1;
  32.         
  33.         if(humi_value < rh_low || humi_value > rh_high || temp_value < temp_low || temp_value > temp_high || co2 < co2_low || co2 > co2_high)
  34.                 Buzzer = 0;
  35.         else Buzzer = 1;
  36.                
  37. }

  38. void main()
  39. {
  40.         flcd1602_init();
  41.         InitUart();        
  42.         while(1)
  43.         {
  44.                 Display();
  45.                 DHT11_receive();
  46.                 co2 = (adc0832(0) * 12);
  47.                 key();
  48.                 judge();
  49.                 printf("T:%d,RH:%d,CO2:%d\r\n",(int)temp_value,(int)humi_value,(int)co2);
  50.         }
  51. }
復(fù)制代碼
Proteus8.8仿真程序資料51hei下載地址,大家下載一個串口調(diào)試助手調(diào)試一下看看:
上位機通訊.zip (130.27 KB, 下載次數(shù): 40)

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表