描述
<div class="document"> </div>
<h3 class="document">* 1、项目功能介绍</h3>
<div class="document"><hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">这个项目是一个基于<strong>STM32G030K6T6</strong>微控制器的桌面温湿度检查仪。该设备小巧轻便,既可以作为桌面装饰美化环境,也可以在闲暇时用来查看当前环境的温度和湿度。为了达到更长的电池续航时间,设备采用了节能设计,平时处于低功耗的<strong>睡眠模式</strong>,通过按下外部按键即可唤醒进行数据采集,并将结果显示在数码管上。系统使用两节5号电池供电,大约提供3V的电压,这样的设计使得在睡眠唤醒的工作模式下,两节电池可以使用非常长的时间。主控芯片<strong>STM32G030K6T6</strong>内置丰富的外设接口,如<strong>SPI</strong>、<strong>I²C</strong>等,可以轻松地与<strong>盛思睿SHT40</strong>温湿度传感器通信,获取准确的温湿度数据。整个系统不仅实用,而且具有一定的趣味性和装饰性,非常适合DIY爱好者制作。</p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*2、项目属性</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><strong><span style="color: #95a5a6; font-size: 14px;">该项目非首次公开,也非原创,同时也没有获奖,按照立创开源平台的开源项目进行的复刻。</span></strong></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">* 3、开源协议</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><strong>开源协议:GPL 3.0</strong></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*4、硬件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="font-size: 14pt;">1.电源部分</span></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">采用了两节5号电池供电,供电电压3V。使用PMOS管来防止电压输入反接烧坏电路。使用两个10kΩ电阻分压来测量电池电压,电阻精度选择1%,使得测量电压尽量精准。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/b92099e7809c41fbac5077a46a222557.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">2.主控部分</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">选用了<strong>32.768K</strong>的晶振来提升时钟准确性。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/49cd8e3323b344aebd8b3b5b4fc2e8f0.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/222621c2471848818051335cd139f6a8.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><strong>注意:在布线时晶振尽量靠近芯片,减少干扰。</strong></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">3.显示部分</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">显示部分需要显示温湿度,所以采用了两个3位数码管,即显示精度为0.1。3位数码管为了方便控制数码管显示,我们采用了3个移位寄存器芯片<strong>SN74HC595PWR</strong>芯片来控制数码管显示。2个移位寄存器芯片各控制一个数码管的段选即控制数码管显示什么;另一个芯片控制两个数码管的位选,即哪个数码管3位中的那一位显示。这样画电路很容易实现软件,我们只需要先控制位选,再控制段选就可以了。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"> <img src="//image.lceda.cn/oshwhub/bfb7710c1fbc44e0b86f6a518c0acbc6.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/b8b5de9defa6458e946ebe9fb09bdcdb.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">4.传感器部分</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">温湿度传感器采用的是盛思锐的SHT40,可以同时测量温湿度,采用I2C读取温湿度。这里采用了<strong>10K</strong>上拉电阻,给I2C通信过程中一个确定的信号,保证通信质量和稳定。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/f79c9ddadc97415282611959b81d2c41.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">5.按键和LED部分</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">显示结束后,芯片将进入睡眠模式,延长使用时间。这里采用按键用来唤醒芯片进行显示温湿度。LED灯的设计可以用来检测<strong>SN74HC595PWR</strong>芯片和电灯科技。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/d2190a061ed14da0bd8d14ef937e1850.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/70d193624e16404db52563d3de43ade6.png"></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*5、软件部分</h3>
<hr class="horizontal-splitline normal-bold-2"></div>
<div class="document">STM32配置可以使用<strong>STM32CubeProgramme</strong>r配置,也可以使用<strong>STM32CubeProgrammer</strong>配置完时钟和下载口后,自己写。</div>
<div class="document"> </div>
<div class="document">1.I2C配置</div>
<div class="document">这里使用硬件I2C,配置完引脚后,直接调用I2C硬件读取函数。按照SHT40的数据手册,I2C地址是0X44,寻址是 7 位 I2C 地址,后跟第八位来指示通信方向: “0” 表示向从设备传输数据,即“写”,而 “1” 表示“读”请求,所以在调用函数时,要注意地址。</div>
<div class="document">根据<a href="https://item.szlcsc.com/24072575.html?fromZone=s_s__%2522c22437501%2522" target="_blank">数据手册</a>,对读取的数据进行如下处理,代码如下:</div>
<div class="document"><code>void SHT40_Read_RHData(float *temperature,float *humidity)</code><br><code>{</code><br><code> uint8_t writeData[1] = {0xFD};</code><br><code> uint8_t readData[6] = {0};</code><br><code> uint32_t tempData = 0;</code><br><code> HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)SHT40_Write, (uint8_t *)writeData, 1, HAL_MAX_DELAY);</code><br><code> HAL_Delay(10);</code><br><code> HAL_I2C_Master_Receive(&hi2c1, (uint16_t)SHT40_Read, (uint8_t *)readData, 6, HAL_MAX_DELAY);</code><br><code> </code><br><code> tempData = readData[0]<<8 | readData[1];</code><br><code> *temperature = (tempData * 175.0f) / 65535.0f - 45;</code><br><code> </code><br><code> tempData = readData[3]<<8 | readData[4];</code><br><code> *humidity = (tempData * 125.0f) / 65535.0f - 6;</code><br><code>}</code></div>
<div class="document">这里采用指针获取数据。</div>
<div class="document"> </div>
<div class="document">2.按键配置</div>
<div class="document">唤醒引脚配置中断,使用中断判断按键确实被按下,按键配置是上拉,根据电路,按键按下是接低,则是下降沿。中断配置成下降沿触发回调,按下后调用I2C读取温湿度。</div>
<div class="document">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">3.数码管显示</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">数码管引脚配置采用标准配置,依次配置时钟、引脚、模式、上下拉、速度、复用。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> <code>/* GPIO Ports Clock Enable */</code><br><code> __HAL_RCC_GPIOB_CLK_ENABLE();</code><br><code> __HAL_RCC_GPIOC_CLK_ENABLE();</code><br><code> </code><br><code> /*Configure GPIO pins : PBPin PBPin */</code><br><code> GPIO_InitStruct.Pin = LED1_SER_Pin|LED_TEST_Pin;</code><br><code> GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;</code><br><code> GPIO_InitStruct.Pull = GPIO_NOPULL;</code><br><code> GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;</code><br><code> HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);</code><br><code> </code><br><code> /*Configure GPIO pins : PAPin PAPin PAPin PAPin</code><br><code> PAPin PAPin PAPin PAPin */</code><br><code> GPIO_InitStruct.Pin = LED2_SER_Pin|LED2_RCLK_Pin|LED2_SCLK_Pin|DIG_SER_Pin</code><br><code> |DIG_RCLK_Pin|DIG_SCLK_Pin|LED1_RCLK_Pin|LED1_SCLK_Pin;</code><br><code> GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;</code><br><code> GPIO_InitStruct.Pull = GPIO_NOPULL;</code><br><code> GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;</code><br><code> HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);</code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">引脚配置完成后,就可以测试数码管显示了。按照<strong>SN74HC595PWR</strong>的时序图来进行数据传输来显示。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><img src="//image.lceda.cn/oshwhub/4b57337e93c34fe989656a23e4d9bf08.png"></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">数据输入流程:</p>
<ol>
<li><strong>数据输入阶段</strong>:在<strong>SRCLK</strong>的上升沿,<strong>SER</strong>上的数据被加载到移位寄存器的第一个位置。</li>
<li><strong>数据移位阶段</strong>:随着<strong>SRCLK</strong>的持续上升沿,数据逐位向右移动,直到到达最后一个位置。</li>
<li><strong>数据锁定阶段</strong>:在<strong>RCLK</strong>的上升沿,移位寄存器的内容被锁存在输出端口。</li>
<li><strong>数据输出阶段</strong>:此时,输出端口(<strong>QA-QH</strong>)反映出移位寄存器的内容。</li>
<li><strong>清零阶段</strong>:当<strong>SRCLR</strong>变为低电平,移位寄存器被清零。所以在硬件电路中<strong>SRCLR</strong>接了3V。</li>
</ol>
<p>按照这个流程,控制一个数码管显示需要8位数据,所以使用for循环输入一个8位数据,这里我们先传高位再传低位数据。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;"><code><strong> for(i = 0;i < 8;i++)</strong></code><br><code><strong> {</strong></code><br><code><strong> if(((sendValue << i)&0x80)!=0) //如果数据第一位是1</strong></code><br><code><strong> {</strong></code><br><code><strong> HAL_GPIO_WritePin(LED1_SER_GPIO_Port,LED1_SER_Pin,GPIO_PIN_SET); //高电平</strong></code><br><code><strong> }</strong></code><br><code><strong> else</strong></code><br><code><strong> {</strong></code><br><code><strong> HAL_GPIO_WritePin(LED1_SER_GPIO_Port,LED1_SER_Pin,GPIO_PIN_RESET); //低电平</strong></code><br><code><strong> }</strong></code><br><code><strong> HAL_GPIO_WritePin(LED1_SCLK_GPIO_Port,LED1_SCLK_Pin,GPIO_PIN_RESET); //产生一个SCLK上升沿</strong></code><br><code><strong> HAL_GPIO_WritePin(LED1_SCLK_GPIO_Port,LED1_SCLK_Pin,GPIO_PIN_SET);</strong></code><br><code><strong> }</strong></code><br><code><strong> HAL_GPIO_WritePin(LED1_RCLK_GPIO_Port,LED1_RCLK_Pin,GPIO_PIN_RESET); //产生一个RCLK上升沿</strong></code><br><code><strong> HAL_GPIO_WritePin(LED1_RCLK_GPIO_Port,LED1_RCLK_Pin,GPIO_PIN_SET);</strong></code></p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">再控制数码管之前我们应该把对应数码管使能,即控制第三个<strong>SN74HC595PWR</strong>芯片控制数码管的使能。代码参考上面,把控制引脚换成第三个<strong>SN74HC595PWR</strong>芯片的DIG_RCLK_Pin、DIG_SCLK_Pin、DIG_SER_Pin即可。</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt pap-left-indent-1.6em" style="line-height: 1.8;">具体驱动代码:</p>
<p><code>void SN74HC595_Send_Data(unsigned char sn_num,unsigned int sendValue)</code><br><code>{</code><br><code> uint8_t i = 0;</code><br><code> if(sn_num == SN_LED1) //第一个数码管</code><br><code> {</code><br><code> for(i = 0;i < 8;i++)</code><br><code> {</code><br><code> if(((sendValue << i)&0x80)!=0) //如果数据第一位是1</code><br><code> {</code><br><code> HAL_GPIO_WritePin(LED1_SER_GPIO_Port,LED1_SER_Pin,GPIO_PIN_SET); //高电平</code><br><code> }</code><br><code> else</code><br><code> {</code><br><code> HAL_GPIO_WritePin(LED1_SER_GPIO_Port,LED1_SER_Pin,GPIO_PIN_RESET); //低电平</code><br><code> }</code><br><code> HAL_GPIO_WritePin(LED1_SCLK_GPIO_Port,LED1_SCLK_Pin,GPIO_PIN_RESET); //产生一个SCLK上升沿</code><br><code> HAL_GPIO_WritePin(LED1_SCLK_GPIO_Port,LED1_SCLK_Pin,GPIO_PIN_SET);</code><br><code> }</code><br><code> HAL_GPIO_WritePin(LED1_RCLK_GPIO_Port,LED1_RCLK_Pin,GPIO_PIN_RESET); //产生一个RCLK上升沿</code><br><code> HAL_GPIO_WritePin(LED1_RCLK_GPIO_Port,LED1_RCLK_Pin,GPIO_PIN_SET);</code><br><code> }</code><br><code> else if(sn_num == SN_LED2)</code><br><code> {</code><br><code> for(i = 0;i < 8;i++)</code><br><code> {</code><br><code> if(((sendValue << i)&0x80)!=0)</code><br><code> {</code><br><code> HAL_GPIO_WritePin(LED2_SER_GPIO_Port,LED2_SER_Pin,GPIO_PIN_SET);</code><br><code> }</code><br><code> else</code><br><code> {</code><br><code> HAL_GPIO_WritePin(LED2_SER_GPIO_Port,LED2_SER_Pin,GPIO_PIN_RESET);</code><br><code> }</code><br><code> HAL_GPIO_WritePin(LED2_SCLK_GPIO_Port,LED2_SCLK_Pin,GPIO_PIN_RESET);</code><br><code> HAL_GPIO_WritePin(LED2_SCLK_GPIO_Port,LED2_SCLK_Pin,GPIO_PIN_SET);</code><br><code> }</code><br><code> HAL_GPIO_WritePin(LED2_RCLK_GPIO_Port,LED2_RCLK_Pin,GPIO_PIN_RESET);</code><br><code> HAL_GPIO_WritePin(LED2_RCLK_GPIO_Port,LED2_RCLK_Pin,GPIO_PIN_SET); </code><br><code> }</code><br><code> else if(sn_num == SN_DIG)</code><br><code> {</code><br><code> for(i = 0;i < 8;i++)</code><br><code> {</code><br><code> if(((sendValue << i)&0x80)!=0)</code><br><code> {</code><br><code> HAL_GPIO_WritePin(DIG_SER_GPIO_Port,DIG_SER_Pin,GPIO_PIN_SET);</code><br><code> }</code><br><code> else</code><br><code> {</code><br><code> HAL_GPIO_WritePin(DIG_SER_GPIO_Port,DIG_SER_Pin,GPIO_PIN_RESET);</code><br><code> }</code><br><code> HAL_GPIO_WritePin(DIG_SCLK_GPIO_Port,DIG_SCLK_Pin,GPIO_PIN_RESET);</code><br><code> HAL_GPIO_WritePin(DIG_SCLK_GPIO_Port,DIG_SCLK_Pin,GPIO_PIN_SET);</code><br><code> }</code><br><code> HAL_GPIO_WritePin(DIG_RCLK_GPIO_Port,DIG_RCLK_Pin,GPIO_PIN_RESET);</code><br><code> HAL_GPIO_WritePin(DIG_RCLK_GPIO_Port,DIG_RCLK_Pin,GPIO_PIN_SET); </code><br><code> }</code><br><code>}</code></p>
<p><code>/*</code></p>
<p><code>延时函数</code></p>
<p><code>单位:us</code></p>
<p><code>*/</code></p>
<p><code>void Delay_us(uint32_t us)</code><br><code>{</code><br><code> __IO uint32_t delay;</code><br><code> uint32_t start, ticks;</code><br><code> ticks = us * 64;</code></p>
<p><code> start = SysTick->VAL;</code><br><code> do</code><br><code> {</code><br><code> delay = (start - SysTick->VAL) & 0xFFFFFF; // 防止溢出</code><br><code> } while(delay < ticks);</code><br><code>}</code></p>
<p><code>void ShowNum(uint8_t row, uint8_t column, uint8_t value)</code><br><code>{</code><br><code> if(row == 1)</code><br><code> {</code><br><code> switch(column)</code><br><code> {</code><br><code> case 1: //如果是第一排第一个</code><br><code> SN74HC595_Send_Data(SN_DIG, 0xFE);</code><br><code> break;</code><br><code> case 2:</code><br><code> SN74HC595_Send_Data(SN_DIG, 0xFD);</code><br><code> break;</code><br><code> case 3:</code><br><code> SN74HC595_Send_Data(SN_DIG, 0xFB);</code><br><code> break;</code><br><code> default:</code><br><code> break;</code><br><code> }</code><br><code> </code><br><code> if(column==2)</code><br><code> {</code><br><code> SN74HC595_Send_Data(SN_LED1, sgh_value[value]|0x80); //显示值对应的16进制数</code><br><code> }</code><br><code> else</code><br><code> {</code><br><code> SN74HC595_Send_Data(SN_LED1, sgh_value[value]); //显示值对应的16进制数</code><br><code> }</code><br><code> Delay_us(1000); //大致延时1000us</code><br><code> SN74HC595_Send_Data(SN_LED1, 0x00); //消除阴影</code><br><code> </code><br><code> }</code><br><code> else</code><br><code> {</code><br><code> switch(column)</code><br><code> {</code><br><code> case 1: //如果是第一排第一个</code><br><code> SN74HC595_Send_Data(SN_DIG, 0xF7);</code><br><code> break;</code><br><code> case 2:</code><br><code> SN74HC595_Send_Data(SN_DIG, 0xEF);</code><br><code> break;</code><br><code> case 3:</code><br><code> SN74HC595_Send_Data(SN_DIG, 0xDF);</code><br><code> break;</code><br><code> default:</code><br><code> break;</code><br><code> }</code><br><code> if(column==2)</code><br><code> {</code><br><code> SN74HC595_Send_Data(SN_LED2, sgh_value[value]|0x80); //显示值对应的16进制数</code><br><code> }</code><br><code> else</code><br><code> {</code><br><code> SN74HC595_Send_Data(SN_LED2, sgh_value[value]); //显示值对应的16进制数</code><br><code> </code><br><code> }</code><br><code> Delay_us(1000); //大致延时50us</code></p>
<p><code> SN74HC595_Send_Data(SN_LED2, 0x00); //消除阴影</code><code> </code><br><code> }</code><br><code>}</code></p>
<p>数码显示的数字是0-9段选是固定的,我们把段选按照0-9填充在数组<strong><code>sgh_value</code></strong>中,使数组内容和数据位置对应,显示数字时我们调用相应的数组即可。显示内容的精度是0.1,所以在显示数码管的第二位时,显示是数与0x80与,高位置1则显示小数点。每次显示完成后快速消影,防止影响下次显示。</p>
<div class="document">4.定时器配置</div>
<div class="document">配置一个定时器,这里使用了定时器4,定时30us触发一次中断,在中断里面,我们把读取的温湿度传入数码管显示。</div>
<div class="document"> </div>
<div class="document">5.其余引脚处理</div>
<div class="document">为达到低功耗,把其余没有用到的引脚初始化为模拟模式,既不上拉也不下拉。</div>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*6、BOM清单</h3>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">见附件:BOM</p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">*7、大赛LOGO验证</h3>
<hr class="horizontal-splitline normal-bold-2">
<div class="document"><img src="//image.lceda.cn/oshwhub/52e3e72270c24e42a8a99496c01cb572.png"></div>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">* 8、演示您的项目并录制成视频上传</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">见附件:立创电赛-温湿度检测仪-实物演示</p>
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
</div>
评论(0)