用Keil uVision5编写基于stm32f103c8t6控制hx711模块测得的体重值显示在oled屏幕上的主程序和连线方式
时间: 2024-05-02 12:21:08 浏览: 139
主程序:
```c
#include "stm32f10x.h"
#include "delay.h"
#include "oled.h"
#include "hx711.h"
int main(void)
{
uint32_t weight = 0;
char buffer[10] = {0};
delay_init();
hx711_init();
oled_init();
while(1)
{
weight = hx711_get_value();
sprintf(buffer, "%d", weight);
oled_show_string(0, 0, "Weight: ");
oled_show_string(0, 2, buffer);
oled_show_string(8, 4, "g");
delay_ms(500);
}
}
```
连线方式:
HX711模块 | STM32F103C8T6
---------|-------------
DT | PB14
SCK | PB13
VCC | 3.3V
GND | GND
OLED模块 | STM32F103C8T6
---------|-------------
SCL | PB10
SDA | PB11
VCC | 3.3V
GND | GND
阅读全文