写一个用STM32F103C8T6通过OLED显示数字123的代码
时间: 2023-02-21 12:28:55 浏览: 61
这是一份STM32F103C8T6使用OLED显示数字123的示例代码:
```
#include "stm32f10x.h"
#include "oled.h"
int main(void)
{
OLED_Init();
OLED_ShowNum(0, 0, 123, 3, 16);
while (1)
{
}
}
```
请注意,这份代码仅提供示例,你需要自己实现OLED驱动代码,并确保其与你使用的OLED模块兼容。
相关问题
写一个用STM32F103C8T6通过OLED初始化的代码
以下是STM32F103C8T6通过OLED初始化的C代码示例,需要额外设置I2C总线。
```
#include "stm32f10x.h"
#include "i2c.h"
#define OLED_I2C_ADDRESS 0x78
void OLED_Init(void)
{
uint8_t cmd[2];
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xAE);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xA8);
I2C_WriteByte(0x3F);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xD3);
I2C_WriteByte(0x00);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0x40);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xA1);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xC8);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xDA);
I2C_WriteByte(0x12);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0x81);
I2C_WriteByte(0xCF);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_Write
写一个stm32f103c8t6在OLED屏上显示的代码
我可以回答这个问题。以下是一个简单的示例代码,可以在STM32F103C8T6上使用OLED屏幕显示Hello World:
```
#include "stm32f10x.h"
#include "oled.h"
int main(void)
{
OLED_Init(); // 初始化OLED屏幕
OLED_Clear(); // 清空屏幕
OLED_ShowString(0, 0, "Hello World!"); // 在屏幕上显示Hello World
while (1)
{
}
}
```
请注意,这只是一个简单的示例代码,您需要根据您的具体需求进行修改和优化。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)