#include<Wire.h>// Only needed for Arduino 1.5 and earlier#include"SSD1306Wire.h"// Initialize the OLED displaySSD1306Wiredisplay(0x3c,1,0, GEOMETRY_128_32);boolshowHelloWorld =true;// 初始显示 "hello world"intpercentage =1;// 从 1% 开始unsignedlonglastUpdate =0;// 记录上次更新时间cons...
新建一个项目: #include<Wire.h> // Only needed for Arduino 1.6.5 and earlier#include"SSD1306Wire.h"// Initialize the OLED display using Arduino Wire:SSD1306Wiredisplay(0x3c,1,0,GEOMETRY_128_32);voidsetup(){// put your setup code here, to run once:Serial.begin(115200);//...
display.setCursor(0, 0); // 设置游标位置为(0, 0)display.println("Hello, world!"); // 在屏幕上显示"Hello, world!"display.setTextColor(BLACK, WHITE); // 设置文字颜色为黑底白字,即反色显示 ```这段代码展示了如何在OLED屏幕上显示文本,包括设置字体大小、颜色及位置,通过这些简单的设置,OLED...
display.drawString(0, 0, "hello world");display.display; }voidloop{}效果:比如现在我想要在显示"hello world"之后从1%到100%循环显示。代码如下:#include<Wire.h> // Only needed for Arduino 1.5 and earlier#include"SSD1306Wire.h"// Initialize the OLED displaySSD1306Wire display(0x3c, 1, 0, ...
登录后复制/* 项目名称:OLED多行显示 * 项目日期:2022.03.16 * 项目作者:MRX */#include< Wire.h>#include< Adafruit_GFX.h>#include< Adafruit_SSD1306.h>#defineOLED_RESET 4 Adafruit_SSD1306display(128,64, &Wire,OLED_RESET); void setup() {display.begin(SSD1306_SWITCHCAPVCC,0x3C);display.set...
在“setup()”函数中,我们需要将OLED显示屏的初始化参数设置正确。例如,我们的显示屏分辨率为128x64,因此我们需要将OLED_DISPLAY_WIDTH和OLED_DISPLAY_HEIGHT分别设置为128和64。然后,我们可以编写一些简单的代码来测试显示屏是否正常工作。例如,在“loop()”函数中,我们可以编写一些代码来在显示屏上显示一些文字或...
Adafruit_SSD1306 display(OLED_RESET);static const unsigned char PROGMEM logo[] ={//这里即为我图片显示的内容,为了让内容更不冗长我就删掉了};#if (SSD1306_LCDHEIGHT != 64)#error("Height incorrect, please fix Adafruit_SSD1306.h!");#endifvoid setup() {Serial.begin(9600);display.begin(SSD...
#define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET)...
#define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); 然后在 setup() 函数中添加 1 display.begin(SSD1306_SWITCHCAPVCC, 0x3c); 其中0x3c 是 OLED 显示屏的 I2C 地址。如果你有多个 I2C 设备,那么可以用 I2C 扫描程序来找到每个设备的 I2C 地址。扫描程序在项目的文件库中可以下载: ...
OLED 屏幕对电压要求较为严格,务必确保电源电压正确。动画效果需要注意刷新率,过高的刷新频率可能导致图像不清晰,甚至损坏屏幕。最佳实践 在使用 OLED 显示时,可以利用 clearDisplay() 来清除屏幕,这样能够避免“残影”问题。使用 setTextSize() 和 setTextColor() 来优化文字显示效果,不同的背景和字体大小会有...