找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

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

stm32溫濕度-超聲波-LCD1602結(jié)合項(xiàng)目 附Proteus仿真程序

  [復(fù)制鏈接]
ID:711352 發(fā)表于 2020-7-10 10:23 | 顯示全部樓層 |閱讀模式
程序?qū)崿F(xiàn)功能:
程序基于stm32芯片實(shí)現(xiàn)了控制LED燈亮滅、按鍵控制、串口通信、電機(jī)控制、溫濕度數(shù)據(jù)采集、超聲波測距、LCD顯示屏顯示內(nèi)容這幾個(gè)功能,并用proteus8進(jìn)行仿真。
1.電路圖
     1、我設(shè)計(jì)的電路圖如下所示:
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
圖片1.png

2. 程序功能介紹
程序總共包括控制LED燈亮滅、按鍵控制、串口通信、電機(jī)控制、溫濕度數(shù)據(jù)采集、超聲波測距、LCD顯示屏顯示內(nèi)容這幾個(gè)功能,以下是這些功能的介紹:
2.1. LED燈亮滅與按鍵控制
程序默認(rèn)運(yùn)行時(shí),兩個(gè)LED燈會(huì)被點(diǎn)亮。當(dāng)按下按鈕后,兩個(gè)LED燈會(huì)閃爍。

2.2. 串口通信
程序運(yùn)行時(shí),虛擬終端接串口通信用到的接收端和發(fā)送端,通過配置波特率、傳輸?shù)钠媾夹r?yàn)位、停止位、字長以及重定向,將printf函數(shù)打印的內(nèi)容打印到虛擬終端上。
2.3. 電機(jī)的控制
通過L298芯片,改變功率,來控制電機(jī)的轉(zhuǎn)動(dòng)。

2.4. 溫濕度數(shù)據(jù)采集
DHT11溫濕度傳感器來采集溫濕度信息。
通過了解DHT11的工作時(shí)序,設(shè)計(jì)好對應(yīng)的延時(shí)函數(shù),進(jìn)行數(shù)據(jù)采集,同時(shí)通過循環(huán)將每次采集的數(shù)據(jù)打印在虛擬終端上。
2.5. 超聲波測距
通過超聲波測距模塊來進(jìn)行測距。
通過了解超聲波測距模塊的時(shí)序,利用定時(shí)器,采集測到的距離,并且通過循環(huán)打印在虛擬終端上。
2.6. LCD液晶顯示器顯示數(shù)據(jù)
客戶端可以通過發(fā)送database”字符串進(jìn)入到數(shù)據(jù)庫的相關(guān)服務(wù),在選擇相應(yīng)功能執(zhí)行。如下圖所示:
通過了解LM16016l中各引腳功能,相關(guān)控制指令以及寫時(shí)序和讀時(shí)序,在程序運(yùn)行時(shí),在顯示屏上打印“hello”。
3.具體代碼如下:
* 文件名  : UltrasonicWave.c
* 描述    :超聲波測距模塊,UltrasonicWave_Configuration()函數(shù)
             初始化超聲模塊,UltrasonicWave_StartMeasure()函數(shù)
                         啟動(dòng)測距,并將測得的數(shù)據(jù)通過串口1打印出來         
* 實(shí)驗(yàn)平臺(tái):野火STM32開發(fā)板
* 硬件連接:------------------
*          | PC8  - TRIG      |
*          | PC9  - ECHO      |
*           ------------------
* 庫版本  :ST3.5.0
UltrasonicWave.H

  1. #ifndef __UltrasonicWave_H
  2. #define        __UltrasonicWave_H

  3. void UltrasonicWave_Configuration(void);               //對超聲波模塊初始化
  4. void UltrasonicWave_StartMeasure(void);                //開始測距,發(fā)送一個(gè)>10us的脈沖,然后測量返回的高電平時(shí)間

  5. #endif /* __UltrasonicWave_H */
復(fù)制代碼

UltrasonicWave.c
*********************************************************************************/
#include "./Wave/UltrasonicWave.h"
#include "./usart/bsp_usart.h"
#include "./Tim2/TIM2.h"

#define        TRIG_PORT      GPIOC                //TRIG      
#define        ECHO_PORT      GPIOC                //ECHO
#define        TRIG_PIN       GPIO_Pin_8   //TRIG      
#define        ECHO_PIN       GPIO_Pin_9        //ECHO   

unsigned short int UltrasonicWave_Distance;      //計(jì)算出的距離   

/*
* 函數(shù)名:DelayTime_us
* 描述  :1us延時(shí)函數(shù)
* 輸入  :Time           延時(shí)的時(shí)間 US
* 輸出  :無        
*/
void DelayTime_us(int Time)   
{
   unsigned char i;
   for ( ; Time>0; Time--)
     for ( i = 0; i < 72; i++ );
}

/*
* 函數(shù)名:UltrasonicWave_Configuration
* 描述  :超聲波模塊的初始化
* 輸入  :無
* 輸出  :無        
*/
void UltrasonicWave_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;        
                 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
   
  GPIO_InitStructure.GPIO_Pin = TRIG_PIN;                                         //PC8接TRIG
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                     //設(shè)為推挽輸出模式
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                 
  GPIO_Init(TRIG_PORT, &GPIO_InitStructure);                         //初始化外設(shè)GPIO

  GPIO_InitStructure.GPIO_Pin = ECHO_PIN;                                     //PC9接ECH0
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;                 //設(shè)為輸入
  GPIO_Init(ECHO_PORT,&GPIO_InitStructure);                                                 //初始化GPIOA
}

/*
* 函數(shù)名:UltrasonicWave_CalculateTime
* 描述  :計(jì)算距離
* 輸入  :無
* 輸出  :無        
*/
void UltrasonicWave_CalculateTime(void)
{
   UltrasonicWave_Distance=TIM_GetCounter(TIM2)*5*34/2000;
}

/*
* 函數(shù)名:UltrasonicWave_StartMeasure
* 描述  :開始測距,發(fā)送一個(gè)>10us的脈沖,然后測量返回的高電平時(shí)間
* 輸入  :無
* 輸出  :無        
*/
void UltrasonicWave_StartMeasure(void)
{
  GPIO_SetBits(TRIG_PORT,TRIG_PIN);                   //送>10US的高電平
  DelayTime_us(20);                                      //延時(shí)20US
  GPIO_ResetBits(TRIG_PORT,TRIG_PIN);
  
  while(!GPIO_ReadInputDataBit(ECHO_PORT,ECHO_PIN));                     //等待高電平
  TIM_Cmd(TIM2, ENABLE);                                             //開啟時(shí)鐘
  while(GPIO_ReadInputDataBit(ECHO_PORT,ECHO_PIN));                         //等待低電平
  TIM_Cmd(TIM2, DISABLE);                                                         //定時(shí)器2失能
  UltrasonicWave_CalculateTime();                                                                         //計(jì)算距離
  TIM_SetCounter(TIM2,0);

        printf("\r\ndistance:%d%d cm\r\n",UltrasonicWave_Distance/256,UltrasonicWave_Distance%256);        
            
}

motor.h
  1. #ifndef __MOTOR_H
  2. #define        __MOTOR_H
  3. #include "stm32f10x.h"
  4. #define  DEBUG_MOTOR_CLK        RCC_APB2Periph_GPIOB
  5. #define  MOTOR_GPIO                        GPIOB
  6. #define         Motor_Pin_1                GPIO_Pin_13        
  7. #define         Motor_Pin_2                GPIO_Pin_14
  8. void motor_init(void);
  9. void motor_stop(void);

  10. #endif
復(fù)制代碼
motor.c:
  1. #include <./MOTOR/motor.h>
  2. //初始化電機(jī),讓電機(jī)跑起來
  3. void motor_init(void)
  4. {
  5.         GPIO_InitTypeDef GPIO_InitStructure;
  6.         GPIO_InitStructure.GPIO_Pin = Motor_Pin_1 | Motor_Pin_2;
  7.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  8.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  9.         GPIO_Init(MOTOR_GPIO, &GPIO_InitStructure);
  10.         GPIO_SetBits(MOTOR_GPIO,Motor_Pin_1);
  11.         GPIO_ResetBits(MOTOR_GPIO,Motor_Pin_2);
  12. }
  13. //讓電機(jī)停止
  14. void motor_stop(void)
  15. {
  16.         GPIO_InitTypeDef GPIO_InitStructure;
  17.         GPIO_InitStructure.GPIO_Pin = Motor_Pin_1 | Motor_Pin_2;
  18.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  19.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  20.         GPIO_Init(MOTOR_GPIO, &GPIO_InitStructure);
  21.         GPIO_SetBits(MOTOR_GPIO,Motor_Pin_1);
  22.         GPIO_SetBits(MOTOR_GPIO,Motor_Pin_2);
  23. }
復(fù)制代碼
溫濕度.H
  1. #ifndef __DHT11_H
  2. #define        __DHT11_H
  3. #include "stm32f10x.h"

  4. /************************** DHT11 數(shù)據(jù)類型定義********************************/
  5. typedef struct
  6. {
  7.         uint8_t  humi_int;                //濕度的整數(shù)部分
  8.         uint8_t  humi_deci;                 //濕度的小數(shù)部分
  9.         uint8_t  temp_int;                 //溫度的整數(shù)部分
  10.         uint8_t  temp_deci;                 //溫度的小數(shù)部分
  11.         uint8_t  check_sum;                 //校驗(yàn)和
  12.                                  
  13. } DHT11_Data_TypeDef;

  14. /************************** DHT11 連接引腳定義********************************/
  15. #define      DHT11_Dout_SCK_APBxClock_FUN              RCC_APB2PeriphClockCmd
  16. #define      DHT11_Dout_GPIO_CLK                       RCC_APB2Periph_GPIOC

  17. #define      DHT11_Dout_GPIO_PORT                      GPIOC
  18. #define      DHT11_Dout_GPIO_PIN                       GPIO_Pin_15

  19. /************************** DHT11 函數(shù)宏定義********************************/
  20. #define      DHT11_Dout_0                                    GPIO_ResetBits ( DHT11_Dout_GPIO_PORT, DHT11_Dout_GPIO_PIN )
  21. #define      DHT11_Dout_1                                    GPIO_SetBits ( DHT11_Dout_GPIO_PORT, DHT11_Dout_GPIO_PIN )

  22. #define      DHT11_Dout_IN()                                  GPIO_ReadInputDataBit ( DHT11_Dout_GPIO_PORT, DHT11_Dout_GPIO_PIN )



  23. /************************** DHT11 函數(shù)聲明 ********************************/
  24. void                     DHT11_Init                      ( void );
  25. uint8_t                  DHT11_Read_TempAndHumidity      ( DHT11_Data_TypeDef * DHT11_Data );
  26. void dht11_delay_ms(int32_t time);
  27. void dht11_delay_us(int32_t time);

  28. #endif /* __DHT11_H */

復(fù)制代碼
溫濕度.c
  1. /**
  2.   ******************************************************************************
  3.   * @file    bsp_dht11.c
  4.   * @author  fire
  5.   * @version V1.0
  6.   * @date    2015-xx-xx
  7.   * @brief   溫濕度傳感器應(yīng)用函數(shù)接口
  8.   ******************************************************************************
  9. */

  10. #include "./dht11/bsp_dht11.h"
  11. #include "./systick/bsp_SysTick.h"
復(fù)制代碼

LCD.H
  1. #ifndef __LCD_H
  2. #define        __LCD_H
  3. #include "stm32f10x.h"
  4. /************************** LCD連接引腳定義********************************/
  5. #define      LCD_Dout_SCK_APBxClock_FUN              RCC_APB2PeriphClockCmd
  6. #define      LCD_Dout_GPIO_CLK                       RCC_APB2Periph_GPIOC

  7. /**************************  LCD函數(shù)********************************/

  8. void LcdWriteCom(uint8_t com);
  9. void LcdGpioInit(void);
  10. void LcdWriteDate(uint8_t date);
  11. void LCD1602Init(void);
  12. void LCD1602WriteCommand(uint8_t comm);
  13. #endif /* __LCD_H */
復(fù)制代碼
LCD.C
  1. #include "./LCD/bsp_lcd.h"  
  2. #include "./systick/bsp_SysTick.h"
  3. uint8_t const table1[]="hello";
  4. /*初始化用到的引腳*/
  5. void LcdGpioInit(void)   
  6. {
  7.         GPIO_InitTypeDef GPIO_InitStruct;
  8.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
  9.          
  10.         GPIO_WriteBit(GPIOC,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12,Bit_RESET);        
  11.          GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
  12.         GPIO_InitStruct.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|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;
  13.   GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  14.         GPIO_Init ( GPIOC, &GPIO_InitStruct);
  15. }
  16. /*******************************************************************************
  17. * 函 數(shù) 名 :write_com
  18. * 函數(shù)功能 :LCD1602 寫指令
  19. * 輸    入 :無
  20. * 輸    出 :無
  21. *******************************************************************************/
  22. void LcdWriteCom(uint8_t com)
  23. {
  24.         Delay_us(20);
  25.         GPIOC->BSRR = 0x00ff0000;
  26.         GPIOC->BSRR = (com);
  27.         GPIO_WriteBit(GPIOC,GPIO_Pin_10,Bit_RESET);        //LCDRS
  28.         GPIO_WriteBit(GPIOC,GPIO_Pin_11,Bit_RESET);        //LCDRW
  29.         GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_RESET);        //LCDEN
  30.         Delay_us(10);
  31.         GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_SET);        //LCDEN
  32.         Delay_us(10);
  33.         GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_RESET);        //LCDEN
  34.         Delay_us(10);
  35. }
  36. /*******************************************************************************
  37. * 函 數(shù) 名 :write_Date
  38. * 函數(shù)功能 :LCD1602 寫數(shù)據(jù)
  39. * 輸    入 :無
  40. * 輸    出 :無
  41. *******************************************************************************/
  42. void LcdWriteDate(uint8_t date)
  43. {
  44.         Delay_us(20);
  45.         GPIOC->BSRR = 0x00ff0000;
  46.         GPIOC->BSRR = (date);
  47.         GPIO_WriteBit(GPIOC,GPIO_Pin_10,Bit_SET);        //LCDRS
  48.         GPIO_WriteBit(GPIOC,GPIO_Pin_11,Bit_RESET);        //LCDRW
  49.         GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_RESET);        //LCDEN
  50.         Delay_us(10);
  51.         GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_SET);        //LCDEN
  52.         Delay_us(10);
  53.         GPIO_WriteBit(GPIOC,GPIO_Pin_12,Bit_RESET);        //LCDEN
  54.         Delay_us(10);
  55. }
  56. /*******************************************************************************
  57. * 函 數(shù) 名 :LCD1602Init
  58. * 函數(shù)功能 :LCD1602初始化
  59. * 輸    入 :無
  60. * 輸    出 :無
  61. *******************************************************************************/
  62. void LCD1602Init(void)
  63. {
  64.         uint8_t index=0;
  65.         Delay_ms(10);
  66.         LcdWriteCom(0x38);  //設(shè)置16*2顯示,8位數(shù)據(jù)接口
  67.         LcdWriteCom(0x0c); //開顯示,顯示光標(biāo)且閃爍
  68.         LcdWriteCom(0x06);//寫一個(gè)指針自動(dòng)加一
  69.         LcdWriteCom(0x01);//清屏  
  70.         Delay_ms(10);//延時(shí)一段時(shí)間時(shí)間,等待LCD1602穩(wěn)定        
  71.         
  72.         LcdWriteCom(0x80);//設(shè)置第一行 數(shù)據(jù)地址指針
  73.         for(index=0;index<13;index++)
  74.                 LcdWriteDate(table1[index]);  //寫入數(shù)據(jù)
  75.         
  76. //        LcdWriteCom(0xc0);//設(shè)置第二行 數(shù)據(jù)地址指針
  77. //        for(index=0;index<7;index++)
  78. //                LcdWriteDate(table2[index]);  //寫入數(shù)據(jù)
  79. }
  80. /*******************************************************************************
  81. * 函 數(shù) 名 :LCD1602WriteCommand
  82. * 函數(shù)功能 :顯示指令到屏幕 U D L R S
  83. * 輸    入 :comm 字符格式
  84. * 輸    出 :無
  85. *******************************************************************************/
  86. void LCD1602WriteCommand(uint8_t comm)
  87. {
  88.         LcdWriteCom(0xc0 + 14);
  89.         LcdWriteDate(comm);  //寫入數(shù)據(jù)   
  90. }
復(fù)制代碼
main.c
  1. /**
  2.   ******************************************************************************
  3.   * @file    main.c
  4.   * @author  fire
  5.   * @version V1.0
  6.   * @date    2020-xx-xx
  7.   * @brief   dht11溫濕度傳感器測試實(shí)驗(yàn)
  8.   ******************************************************************************
  9. */
  10.   
  11. #include "stm32f10x.h"
  12. #include "./systick/bsp_SysTick.h"
  13. #include "./dht11/bsp_dht11.h"
  14. #include "./usart/bsp_usart.h"
  15. #include "./Key/bsp_key.h"
  16. #include "./Led/bsp_led.h"
  17. #include "./LCD/bsp_lcd.h"
  18. #include "./MOTOR/motor.h"
  19. #include "./Tim2/TIM2.h"
  20. #include "./Wave/UltrasonicWave.h"
  21. /**
  22.   * @brief  主函數(shù)
  23.   * @param  無  
  24.   * @retval 無
  25.   */
  26. int main(void)
  27. {
  28.         
  29.         DHT11_Data_TypeDef DHT11_Data;
  30.         RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
  31.         
  32.         
  33.         /* 配置SysTick 為1us中斷一次 */
  34.         SysTick_Init();
  35.         LED_GPIO_Config();
  36.         //LED1_ON;
  37.         LED2_ON;
  38.         LED3_ON;
  39.         motor_init();
  40.         //NVIC_Configuration();
  41.         TIM2_Configuration();
  42.         UltrasonicWave_Configuration();
  43.         LcdGpioInit();
  44.         LCD1602Init();

  45.         USART_Config();//初始化串口1
  46.         NVIC_Configuration();
  47.         printf("\r\n***秉火STM32 dht11 溫濕度傳感器實(shí)驗(yàn)***\r\n");

  48.         /*初始化DTT11的引腳*/
  49.         DHT11_Init();
  50.         //printf("22\n");

  51.         UltrasonicWave_StartMeasure();
  52.                                 dht11_delay_ms(100);
  53.         while(1)
  54.         {
  55.                         //調(diào)用DHT11_Read_TempAndHumidity讀取溫濕度,若成功則輸出該信息
  56.                         if( DHT11_Read_TempAndHumidity ( & DHT11_Data ) == SUCCESS)
  57.                         {
  58.                         
  59.                                 printf("\r\n讀取DHT11成功!\r\n\r\n濕度為%d.%d %RH ,溫度為 %d.%d℃ \r\n",DHT11_Data.humi_int,DHT11_Data.humi_deci,DHT11_Data.temp_int,DHT11_Data.temp_deci);
  60.                         }                        
  61.                         else
  62.                         {
  63.                                 printf("Read DHT11 ERROR!\r\n");
  64.                         }
  65.                         Delay_ms(100);
  66.                         UltrasonicWave_StartMeasure();
  67.                                 dht11_delay_ms(100);
  68.                
  69.                         
  70.                         
  71.                         
  72.                         if( Key_Scan(KEY1_GPIO_PORT,KEY1_GPIO_PIN) == KEY_ON  )
  73.                         {
  74.                                 /*LED2關(guān)閉*/
  75.                                 LED2_OFF;
  76.                                 motor_init();
  77.                                 
  78.                                 
  79.                         }

  80.                         if( Key_Scan(KEY2_GPIO_PORT,KEY2_GPIO_PIN) == KEY_ON  )
  81.                         {
  82.                                 /*LED3關(guān)閉*/
  83.                                 LED3_OFF;        
  84.                         }               
  85.                         
  86.                
  87.                
  88.                
  89.                         
  90.         }
  91.         return 0;

  92.         
  93. }
  94. /*********************************************END OF FILE**********************/
復(fù)制代碼

全部資料51hei下載地址:
stm32溫濕度-超聲波-LCD結(jié)合項(xiàng)目.7z (540.61 KB, 下載次數(shù): 773)


評分

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

查看全部評分

回復(fù)

使用道具 舉報(bào)

ID:304785 發(fā)表于 2020-7-16 23:44 | 顯示全部樓層
這個(gè)是牛的,給樓主點(diǎn)個(gè)贊
回復(fù)

使用道具 舉報(bào)

ID:139339 發(fā)表于 2020-7-30 00:23 | 顯示全部樓層
看到能仿真成功,我也試試
回復(fù)

使用道具 舉報(bào)

ID:935902 發(fā)表于 2021-6-14 19:04 | 顯示全部樓層
為什么keil5顯示

..\..\Output\DHT11.axf: error: L6002U: Could not open file ..\..\output\core_cm3.o: No such file or directory
Finished: 0 information, 0 warning, 0 error and 1 fatal error messages.
"..\..\Output\DHT11.axf" - 1 Error(s), 5 Warning(s).
Target not created.
Build Time Elapsed:  00:00:10
回復(fù)

使用道具 舉報(bào)

ID:934599 發(fā)表于 2021-6-15 09:16 | 顯示全部樓層
LCD液晶顯示器怎么修改顯示
回復(fù)

使用道具 舉報(bào)

ID:935902 發(fā)表于 2021-6-17 11:20 | 顯示全部樓層
撞南墻 發(fā)表于 2021-6-14 19:04
為什么keil5顯示

..\..\Output\DHT11.axf: error: L6002U: Could not open file ..\..\output\core_cm3. ...

把if 改成else if 好了
回復(fù)

使用道具 舉報(bào)

ID:935902 發(fā)表于 2021-6-17 11:22 | 顯示全部樓層
撞南墻 發(fā)表于 2021-6-14 19:04
為什么keil5顯示

..\..\Output\DHT11.axf: error: L6002U: Could not open file ..\..\output\core_cm3. ...

因?yàn)橛脩裘侵形牡脑?/td>
回復(fù)

使用道具 舉報(bào)

ID:387687 發(fā)表于 2022-3-14 12:55 | 顯示全部樓層

看到能仿真成功,我也試試
回復(fù)

使用道具 舉報(bào)

ID:972656 發(fā)表于 2022-5-25 19:07 | 顯示全部樓層
在仿真中
回復(fù)

使用道具 舉報(bào)

ID:972656 發(fā)表于 2022-5-25 19:16 | 顯示全部樓層
*** Using Compiler 'V5.06 update 1 (build 61)', folder: 'E:\keil\ARM\ARMCC\Bin'
Build target 'Target 1'
compiling UltrasonicWave.c...
UltrasonicWave.c(1): error:  #5: cannot open source input file "./Wave/UltrasonicWave.h": No such file or directory
  #include "./Wave/UltrasonicWave.h"
UltrasonicWave.c: 0 warnings, 1 error
compiling w.c...
w.c(11): error:  #5: cannot open source input file "./dht11/bsp_dht11.h": No such file or directory
  #include "./dht11/bsp_dht11.h"
w.c: 0 warnings, 1 error
compiling LCD.c...
LCD.c(1): error:  #5: cannot open source input file "LCD/bsp_LCD.h": No such file or directory
  #include "LCD/bsp_LCD.h"  
LCD.c: 0 warnings, 1 error
compiling main.c...
E:\keil\ARM\PACK\Keil\STM32F1xx_DFP\1.0.5\Device\Include\stm32f10x.h(96): error:  #35: #error directive: "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
   #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
main.c: 0 warnings, 1 error
".\Objects\1.axf" - 4 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:00
回復(fù)

使用道具 舉報(bào)

ID:972656 發(fā)表于 2022-5-25 19:36 | 顯示全部樓層
   #error "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"
回復(fù)

使用道具 舉報(bào)

ID:972656 發(fā)表于 2022-5-25 21:35 | 顯示全部樓層
撞南墻 發(fā)表于 2021-6-14 19:04
為什么keil5顯示

..\..\Output\DHT11.axf: error: L6002U: Could not open file ..\..\output\core_cm3. ...

你這個(gè)好像是目標(biāo)沒有創(chuàng)建
回復(fù)

使用道具 舉報(bào)

ID:1020198 發(fā)表于 2022-5-29 10:56 | 顯示全部樓層
試了一下能仿真成功,牛!
回復(fù)

使用道具 舉報(bào)

ID:1045113 發(fā)表于 2023-4-15 22:25 | 顯示全部樓層
測量出來的距離誤差有點(diǎn)大,把UltrasonicWave_Distance=TIM_GetCounter(TIM2)*5*34/2000;
改成UltrasonicWave_Distance=TIM_GetCounter(TIM2)*0.79;
會(huì)好很多
回復(fù)

使用道具 舉報(bào)

ID:743691 發(fā)表于 2023-4-17 18:41 | 顯示全部樓層
看到能仿真成功,我也試試,不知道8.8能不能行
回復(fù)

使用道具 舉報(bào)

ID:1103550 發(fā)表于 2025-3-7 20:53 | 顯示全部樓層
仿真不了啊。。LCD和串口都沒反應(yīng)。。
回復(fù)

使用道具 舉報(bào)

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

本版積分規(guī)則

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

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

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