找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 6178|回復(fù): 6
打印 上一主題 下一主題
收起左側(cè)

STM32F4xx+LCD1602+DHT11溫濕度實(shí)時(shí)顯示Proteus仿真程序

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)

  1. #include "lcd.h"



  2. void GPIO_Configuration(void)
  3. {
  4.         GPIO_InitTypeDef        GPIO_InitStructure;
  5.         RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
  6.         
  7.         RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);

  8.         
  9.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
  10.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;                           
  11.         GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  12.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;        
  13.         GPIO_Init(LCD_DATA_PORT, &GPIO_InitStructure);                                
  14.         
  15.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;   
  16.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;                           
  17.         GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;        
  18.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;        
  19.         GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;          //éÏà-
  20.         GPIO_Init(GPIOB, &GPIO_InitStructure);                                
  21. }

  22. void LCD1602_Wait_Ready(void)   //¼ì2aÃ|
  23. {
  24.         int8_t sta=0;
  25.         
  26.         DATAOUT(0xff);      //PCè«ÖÃ1
  27.         LCD_RS_Clr();       //RS 0
  28.         LCD_RW_Set();       //RW 1
  29.         do
  30.         {
  31.                 LCD_EN_Set();   //EN 1
  32.                 Delay_ms(10);
  33.                  sta = GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_7); //¶áè¡×′ì¬×Ö   
  34.                 LCD_EN_Clr();   //EN 0
  35.         }while(sta & 0x80);
  36. }

  37. void LCD1602_Write_Cmd(u8 cmd)    //D′èëÖ¸áî
  38. {
  39.         LCD1602_Wait_Ready();     //ÅDÃ|
  40.         LCD_RS_Clr();   
  41.         LCD_RW_Clr();
  42.          DATAOUT(cmd);  
  43.         Delay_us(10);
  44.         LCD_EN_Set();
  45.         LCD_EN_Clr();

  46. }

  47. void LCD1602_Write_Dat(u8 dat)
  48. {
  49.         LCD1602_Wait_Ready();
  50.         LCD_RS_Set();   
  51.         LCD_RW_Clr();   
  52.         DATAOUT(dat);
  53.     Delay_us(10);        
  54.         LCD_EN_Set();  
  55.         LCD_EN_Clr();

  56.         
  57. }

  58. void LCD1602_ClearScreen(void)  //ÇåÆá
  59. {
  60.         LCD1602_Write_Cmd(0x01);
  61.         
  62. }

  63. void LCD1602_Set_Cursor(u8 x, u8 y)   //1a±êéèÖÃλÖÃ
  64. {
  65.         u8 addr;
  66.         
  67.         if (y == 0)
  68.                 addr = 0x00 + x;
  69.         else
  70.                 addr = 0x40 + x;
  71.         LCD1602_Write_Cmd(addr | 0x80);
  72. }

  73. void LCD1602_Show_Str(u8 x, u8 y, char *str)//×Ö·û′®
  74. {
  75.         LCD1602_Set_Cursor(x, y);
  76.         while(*str != '\0')
  77.         {
  78.                 LCD1602_Write_Dat(*str++);
  79.         }
  80. }

  81. void LCD1602_Init(void)//3õê¼»ˉ
  82. {
  83.         GPIO_Configuration();
  84.         LCD1602_Write_Cmd(0x38);        
  85.         LCD1602_Write_Cmd(0x0C);        
  86.         LCD1602_Write_Cmd(0x06);        
  87.         LCD1602_Write_Cmd(0x01);        
  88. }
復(fù)制代碼


全部資料51hei下載地址:
PRoject.7z (68.21 KB, 下載次數(shù): 429)

評(píng)分

參與人數(shù) 2黑幣 +56 收起 理由
yulin11 + 6
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏11 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

來自 2#
ID:78496 發(fā)表于 2021-3-9 11:24 | 只看該作者
打不開啊,工程文件不完整哦,不知道如何配置啊?有人能幫下忙嗎?
回復(fù)

使用道具 舉報(bào)

板凳
ID:781218 發(fā)表于 2020-6-16 23:12 | 只看該作者
這個(gè)幫助很大
回復(fù)

使用道具 舉報(bào)

地板
ID:712295 發(fā)表于 2021-8-4 16:21 | 只看該作者
你好請(qǐng)問能伴你的protues版本發(fā)給我嗎?感激不盡。
回復(fù)

使用道具 舉報(bào)

5#
ID:965153 發(fā)表于 2021-9-9 20:47 | 只看該作者
怎么可以用dht11檢查溫度 當(dāng)溫度大于三十?dāng)z氏度 濕度大于60%時(shí)亮警燈阿
回復(fù)

使用道具 舉報(bào)

6#
ID:622274 發(fā)表于 2022-11-24 10:03 | 只看該作者
cangku.pdsprj 是仿真文件 用Proteus8.8打開,程序工程要如何打開?
回復(fù)

使用道具 舉報(bào)

7#
ID:316613 發(fā)表于 2023-5-19 18:30 | 只看該作者
仿真串口亂碼,讀不到溫濕度數(shù)據(jù)啊
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

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