OLED屏幕有各种形状和尺寸,但目前有两种非常受欢迎的屏幕尺寸。

1)0.96“

2)1.3“

他们也有2种常见的颜色

1)蓝色

2)白色

驱动OLED的芯片常用的有两种。这两种芯片有许多非常相似的设置命令(在大多数情况下相同),但用于显示信息的命令集是不同的,所以你不能只是改变屏幕 - 你需要更改程序/库来适合相应的芯片!

1)SH1106

2)SSD1306

https://item.taobao.com/item.htm?spm=a1z09.2.0.0.91172e8dcnKcE5&id=563407725788&_u=51qf7bf556f8

https://blog.csdn.net/ling3ye/article/details/53399305

https://startingelectronics.org/tutorials/arduino/modules/OLED-128x64-I2C-display/

Arduino Uno OLED接线

下图显示了如何将Geekcreit 0.96英寸OLED I2C显示器连接到Arduino。用于将OLED显示器连接到Arduino Uno的引脚连接如下。

  • OLED GND - Arduino GND
  • OLED VCC - Arduino 5V
  • OLED SCL - Arduino Uno A5
  • OLED SDA - Arduino Uno A4

Arduino MEGA 2560 OLED接线

用于将Arduino MEGA 2560连接到OLED显示器的引脚连接如下。

  • OLED GND - Arduino GND
  • OLED VCC - Arduino 5V
  • OLED SCL - Arduino MEGA 2560引脚21
  • OLED SDA - Arduino MEGA 2560引脚20

ESP8266-07 连线方式

VCC-5v

GND-GND

SCL-D1

SDA-D2

esp8266-12f死活不显示

用于SSD1306和图形功能的ArduinoOLEDI²C库

必须安装两个Arduino库才能开始使用显示器。SSD1306驱动程序库用于初始化显示并提供低级显示功能。GFX库提供用于显示文本,绘图线和圆圈等的图形功能。这两个库都可以从Adafruit获得。

安装SSD1306驱动程序库

1手动安装。下载Adafruit_SSD1306库该库将保存到您的计算机中,名为Adafruit_SSD1306-master.zip

Adafruit_SSD1306-master文件夹从下载的压缩文件复制到Arduino 文件夹中。此文件夹通常位于Windows系统上的Documents→Arduino→库中。在Linux上,它通常位于主文件夹 →Arduino→库中。

最后在Arduino库文件夹中,将Adafruit_SSD1306-master文件夹重命名为Adafruit_SSD1306

2自动安装

安装GFX库

下载Adafruit_GFX库该库保存在您的计算机中,名为Adafruit-GFX-Library-master.zip

Adafruit-GFX-Library-master文件夹从下载的压缩文件复制到Arduino库文件夹,如上面的SSD1306驱动程序所做。

在Arduino库文件夹中,将Adafruit-GFX-Library-master文件夹重命名为Adafruit_GFX

使用

找到显示屏spi的地址,修改成 0x3C(源库代码打开可能是0x3D)

源代码修改

开启 128*64的注释(ESP8266-07使用的是这个正常工作)

关闭源代码 128*32的注释(arduino mega 2560使用的是这个正常工作)

直接烧录

有报错

参看1

mega 2560板子型号选择

ESP8266-07板子型号选择

  1. /**************************************************************************
  2. This is an example for our Monochrome OLEDs based on SSD1306 drivers
  3.  
  4. Pick one up today in the adafruit shop!
  5. ------> http://www.adafruit.com/category/63_98
  6.  
  7. This example is for a 128x32 pixel display using I2C to communicate
  8. 3 pins are required to interface (two I2C and one reset).
  9.  
  10. Adafruit invests time and resources providing this open
  11. source code, please support Adafruit and open-source
  12. hardware by purchasing products from Adafruit!
  13.  
  14. Written by Limor Fried/Ladyada for Adafruit Industries,
  15. with contributions from the open source community.
  16. BSD license, check license.txt for more information
  17. All text above, and the splash screen below must be
  18. included in any redistribution.
  19. **************************************************************************/
  20.  
  21. #include <SPI.h>
  22. #include <Wire.h>
  23. #include <Adafruit_GFX.h>
  24. #include <Adafruit_SSD1306.h>
  25.  
  26. #define SCREEN_WIDTH 128 // OLED display width, in pixels
  27. #define SCREEN_HEIGHT 64 // OLED display height, in pixels
  28.  
  29. // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
  30. #define OLED_RESET -1 //4 Reset pin # (or -1 if sharing Arduino reset pin)
  31. Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
  32.  
  33. #define NUMFLAKES 10 // Number of snowflakes in the animation example
  34.  
  35. #define LOGO_HEIGHT 16
  36. #define LOGO_WIDTH 16
  37. static const unsigned char PROGMEM logo_bmp[] =
  38. { B00000000, B11000000,
  39. B00000001, B11000000,
  40. B00000001, B11000000,
  41. B00000011, B11100000,
  42. B11110011, B11100000,
  43. B11111110, B11111000,
  44. B01111110, B11111111,
  45. B00110011, B10011111,
  46. B00011111, B11111100,
  47. B00001101, B01110000,
  48. B00011011, B10100000,
  49. B00111111, B11100000,
  50. B00111111, B11110000,
  51. B01111100, B11110000,
  52. B01110000, B01110000,
  53. B00000000, B00110000 };
  54.  
  55. void setup() {
  56. Serial.begin(9600);
  57.  
  58. // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  59. if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
  60. Serial.println("SSD1306 allocation failed");
  61. for(;;); // Don't proceed, loop forever
  62. }
  63. Serial.println("success");
  64. // Show initial display buffer contents on the screen --
  65. // the library initializes this with an Adafruit splash screen.
  66. display.display();
  67. delay(2000); // Pause for 2 seconds
  68.  
  69. // Clear the buffer
  70. display.clearDisplay();
  71.  
  72. // Draw a single pixel in white
  73. display.drawPixel(10, 10, WHITE);
  74.  
  75. // Show the display buffer on the screen. You MUST call display() after
  76. // drawing commands to make them visible on screen!
  77. display.display();
  78. delay(2000);
  79. // display.display() is NOT necessary after every single drawing command,
  80. // unless that's what you want...rather, you can batch up a bunch of
  81. // drawing operations and then update the screen all at once by calling
  82. // display.display(). These examples demonstrate both approaches...
  83.  
  84. testdrawline(); // Draw many lines
  85.  
  86. testdrawrect(); // Draw rectangles (outlines)
  87.  
  88. testfillrect(); // Draw rectangles (filled)
  89.  
  90. testdrawcircle(); // Draw circles (outlines)
  91.  
  92. testfillcircle(); // Draw circles (filled)
  93.  
  94. testdrawroundrect(); // Draw rounded rectangles (outlines)
  95.  
  96. testfillroundrect(); // Draw rounded rectangles (filled)
  97.  
  98. testdrawtriangle(); // Draw triangles (outlines)
  99.  
  100. testfilltriangle(); // Draw triangles (filled)
  101.  
  102. testdrawchar(); // Draw characters of the default font
  103.  
  104. testdrawstyles(); // Draw 'stylized' characters
  105.  
  106. testscrolltext(); // Draw scrolling text
  107.  
  108. testdrawbitmap(); // Draw a small bitmap image
  109.  
  110. // Invert and restore display, pausing in-between
  111. display.invertDisplay(true);
  112. delay(1000);
  113. display.invertDisplay(false);
  114. delay(1000);
  115.  
  116. testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
  117. }
  118.  
  119. void loop() {
  120. }
  121.  
  122. void testdrawline() {
  123. int16_t i;
  124.  
  125. display.clearDisplay(); // Clear display buffer
  126.  
  127. for(i=0; i<display.width(); i+=4) {
  128. display.drawLine(0, 0, i, display.height()-1, WHITE);
  129. display.display(); // Update screen with each newly-drawn line
  130. delay(1);
  131. }
  132. for(i=0; i<display.height(); i+=4) {
  133. display.drawLine(0, 0, display.width()-1, i, WHITE);
  134. display.display();
  135. delay(1);
  136. }
  137. delay(250);
  138.  
  139. display.clearDisplay();
  140.  
  141. for(i=0; i<display.width(); i+=4) {
  142. display.drawLine(0, display.height()-1, i, 0, WHITE);
  143. display.display();
  144. delay(1);
  145. }
  146. for(i=display.height()-1; i>=0; i-=4) {
  147. display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
  148. display.display();
  149. delay(1);
  150. }
  151. delay(250);
  152.  
  153. display.clearDisplay();
  154.  
  155. for(i=display.width()-1; i>=0; i-=4) {
  156. display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
  157. display.display();
  158. delay(1);
  159. }
  160. for(i=display.height()-1; i>=0; i-=4) {
  161. display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
  162. display.display();
  163. delay(1);
  164. }
  165. delay(250);
  166.  
  167. display.clearDisplay();
  168.  
  169. for(i=0; i<display.height(); i+=4) {
  170. display.drawLine(display.width()-1, 0, 0, i, WHITE);
  171. display.display();
  172. delay(1);
  173. }
  174. for(i=0; i<display.width(); i+=4) {
  175. display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE);
  176. display.display();
  177. delay(1);
  178. }
  179.  
  180. delay(2000); // Pause for 2 seconds
  181. }
  182.  
  183. void testdrawrect(void) {
  184. display.clearDisplay();
  185.  
  186. for(int16_t i=0; i<display.height()/2; i+=2) {
  187. display.drawRect(i, i, display.width()-2*i, display.height()-2*i, WHITE);
  188. display.display(); // Update screen with each newly-drawn rectangle
  189. delay(1);
  190. }
  191.  
  192. delay(2000);
  193. }
  194.  
  195. void testfillrect(void) {
  196. display.clearDisplay();
  197.  
  198. for(int16_t i=0; i<display.height()/2; i+=3) {
  199. // The INVERSE color is used so rectangles alternate white/black
  200. display.fillRect(i, i, display.width()-i*2, display.height()-i*2, INVERSE);
  201. display.display(); // Update screen with each newly-drawn rectangle
  202. delay(1);
  203. }
  204.  
  205. delay(2000);
  206. }
  207.  
  208. void testdrawcircle(void) {
  209. display.clearDisplay();
  210.  
  211. for(int16_t i=0; i<max(display.width(),display.height())/2; i+=2) {
  212. display.drawCircle(display.width()/2, display.height()/2, i, WHITE);
  213. display.display();
  214. delay(1);
  215. }
  216.  
  217. delay(2000);
  218. }
  219.  
  220. void testfillcircle(void) {
  221. display.clearDisplay();
  222.  
  223. for(int16_t i=max(display.width(),display.height())/2; i>0; i-=3) {
  224. // The INVERSE color is used so circles alternate white/black
  225. display.fillCircle(display.width() / 2, display.height() / 2, i, INVERSE);
  226. display.display(); // Update screen with each newly-drawn circle
  227. delay(1);
  228. }
  229.  
  230. delay(2000);
  231. }
  232.  
  233. void testdrawroundrect(void) {
  234. display.clearDisplay();
  235.  
  236. for(int16_t i=0; i<display.height()/2-2; i+=2) {
  237. display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,
  238. display.height()/4, WHITE);
  239. display.display();
  240. delay(1);
  241. }
  242.  
  243. delay(2000);
  244. }
  245.  
  246. void testfillroundrect(void) {
  247. display.clearDisplay();
  248.  
  249. for(int16_t i=0; i<display.height()/2-2; i+=2) {
  250. // The INVERSE color is used so round-rects alternate white/black
  251. display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,
  252. display.height()/4, INVERSE);
  253. display.display();
  254. delay(1);
  255. }
  256.  
  257. delay(2000);
  258. }
  259.  
  260. void testdrawtriangle(void) {
  261. display.clearDisplay();
  262.  
  263. for(int16_t i=0; i<max(display.width(),display.height())/2; i+=5) {
  264. display.drawTriangle(
  265. display.width()/2 , display.height()/2-i,
  266. display.width()/2-i, display.height()/2+i,
  267. display.width()/2+i, display.height()/2+i, WHITE);
  268. display.display();
  269. delay(1);
  270. }
  271.  
  272. delay(2000);
  273. }
  274.  
  275. void testfilltriangle(void) {
  276. display.clearDisplay();
  277.  
  278. for(int16_t i=max(display.width(),display.height())/2; i>0; i-=5) {
  279. // The INVERSE color is used so triangles alternate white/black
  280. display.fillTriangle(
  281. display.width()/2 , display.height()/2-i,
  282. display.width()/2-i, display.height()/2+i,
  283. display.width()/2+i, display.height()/2+i, INVERSE);
  284. display.display();
  285. delay(1);
  286. }
  287.  
  288. delay(2000);
  289. }
  290.  
  291. void testdrawchar(void) {
  292. display.clearDisplay();
  293.  
  294. display.setTextSize(1); // Normal 1:1 pixel scale
  295. display.setTextColor(WHITE); // Draw white text
  296. display.setCursor(0, 0); // Start at top-left corner
  297. display.cp437(true); // Use full 256 char 'Code Page 437' font
  298.  
  299. // Not all the characters will fit on the display. This is normal.
  300. // Library will draw what it can and the rest will be clipped.
  301. for(int16_t i=0; i<256; i++) {
  302. if(i == '\n') display.write(' ');
  303. else display.write(i);
  304. }
  305.  
  306. display.display();
  307. delay(2000);
  308. }
  309.  
  310. void testdrawstyles(void) {
  311. display.clearDisplay();
  312.  
  313. display.setTextSize(1); // Normal 1:1 pixel scale
  314. display.setTextColor(WHITE); // Draw white text
  315. display.setCursor(0,0); // Start at top-left corner
  316. display.println(F("Hello, world!"));
  317.  
  318. display.setTextColor(BLACK, WHITE); // Draw 'inverse' text
  319. display.println(3.141592);
  320.  
  321. display.setTextSize(2); // Draw 2X-scale text
  322. display.setTextColor(WHITE);
  323. display.print(F("0x")); display.println(0xDEADBEEF, HEX);
  324.  
  325. display.display();
  326. delay(2000);
  327. }
  328.  
  329. void testscrolltext(void) {
  330. display.clearDisplay();
  331.  
  332. display.setTextSize(2); // Draw 2X-scale text
  333. display.setTextColor(WHITE);
  334. display.setCursor(10, 0);
  335. display.println(F("scroll"));
  336. display.display(); // Show initial text
  337. delay(100);
  338.  
  339. // Scroll in various directions, pausing in-between:
  340. display.startscrollright(0x00, 0x0F);
  341. delay(2000);
  342. display.stopscroll();
  343. delay(1000);
  344. display.startscrollleft(0x00, 0x0F);
  345. delay(2000);
  346. display.stopscroll();
  347. delay(1000);
  348. display.startscrolldiagright(0x00, 0x07);
  349. delay(2000);
  350. display.startscrolldiagleft(0x00, 0x07);
  351. delay(2000);
  352. display.stopscroll();
  353. delay(1000);
  354. }
  355.  
  356. void testdrawbitmap(void) {
  357. display.clearDisplay();
  358.  
  359. display.drawBitmap(
  360. (display.width() - LOGO_WIDTH ) / 2,
  361. (display.height() - LOGO_HEIGHT) / 2,
  362. logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
  363. display.display();
  364. delay(1000);
  365. }
  366.  
  367. #define XPOS 0 // Indexes into the 'icons' array in function below
  368. #define YPOS 1
  369. #define DELTAY 2
  370.  
  371. void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
  372. int8_t f, icons[NUMFLAKES][3];
  373.  
  374. // Initialize 'snowflake' positions
  375. for(f=0; f< NUMFLAKES; f++) {
  376. icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
  377. icons[f][YPOS] = -LOGO_HEIGHT;
  378. icons[f][DELTAY] = random(1, 6);
  379. Serial.print(F("x: "));
  380. Serial.print(icons[f][XPOS], DEC);
  381. Serial.print(F(" y: "));
  382. Serial.print(icons[f][YPOS], DEC);
  383. Serial.print(F(" dy: "));
  384. Serial.println(icons[f][DELTAY], DEC);
  385. }
  386.  
  387. for(;;) { // Loop forever...
  388. display.clearDisplay(); // Clear the display buffer
  389.  
  390. // Draw each snowflake:
  391. for(f=0; f< NUMFLAKES; f++) {
  392. display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
  393. }
  394.  
  395. display.display(); // Show the display buffer on the screen
  396. delay(200); // Pause for 1/10 second
  397.  
  398. // Then update coordinates of each flake...
  399. for(f=0; f< NUMFLAKES; f++) {
  400. icons[f][YPOS] += icons[f][DELTAY];
  401. // If snowflake is off the bottom of the screen...
  402. if (icons[f][YPOS] >= display.height()) {
  403. // Reinitialize to a random position, just off the top
  404. icons[f][XPOS] = random(1 - LOGO_WIDTH, display.width());
  405. icons[f][YPOS] = -LOGO_HEIGHT;
  406. icons[f][DELTAY] = random(1, 6);
  407. }
  408. }
  409. }
  410. }

  

https://item.taobao

.com/item.htm?spm=a1z09.2.0.0.91172e8dcnKcE5&id=562158712128&_u=51qf7bf525e7

OLED液晶屏幕(1)OLED液晶屏幕ssd1306驱动芯片 arduino运行 ESP8266-07可以 12f不可以的更多相关文章

  1. Arduino 基于 ESP8266 配置WIFI模块

    Arduino 基于 ESP8266 配置WIFI模块 使用ESP8266作为服务器,使用浏览器访问该服务器,从而控制LED灯 选择 [文件]->[示例]->[ESP8266WIFI]-& ...

  2. Arduino 配置 ESP8266环境

    Arduino 配置 ESP8266环境 将 http://arduino.esp8266.com/stable/package_esp8266com_index.json 添加到 [附加开发板管理器 ...

  3. 0.96寸OLED显示屏驱动手册(SSD1306)

    MCU IIC接口 IIC通信接口由从地址位SA0,IIC总线数据信号SDA(输出SDAout/D2和输入SDAin /D1)和IIC总线时钟信号SCL(D0).不管是数据线还是时钟线都需要连接上拉电 ...

  4. Arduino运行时突然[卡死在某一行/立即重启/串口输出乱码/程序执行不正常]的可能原因

    1.这一行是分配内存,而内存不够了(Arduino uno只有2k) 2.内存本身已经只剩一点点了,于是就有莫名其妙的问题 3.没有调用Wire.begin().xx.setup()之类的操作!

  5. Arduino UNO +ESP8266采集数据上传到贝壳网

    集成电路设计大赛赛程将至,我现在还是毫无头绪,然后又报了一个互联网+,比赛报了,东西就必须出来,时间很紧的情况下,所以选择了开源的arduino的进行完成.从开始接触Arduino到完成工程,前前后后 ...

  6. Arduino和ESP8266引脚图

    Arduino的引脚图 https://www.geek-workshop.com/thread-11826-1-1.html ESP8266 https://item.taobao.com/item ...

  7. esp8266(3) Arduino通过ESP8266连接和获取网站源代码

    http://www.plclive.com/a/tongxinjiekou/2016/0422/374.html 在上一篇8266的基础上,这一篇做个具体的连接网站的例子,供大家参考.上一篇基础篇请 ...

  8. arduino 配置 esp8266

    在连接之前,先把程序下载到arduino中,很简单,就是定义了软口.如果中间要改动程序,要把rx和tx的连线去掉,不然下载程序可能失败. ; ; void setup() { pinMode(rx,I ...

  9. 【Arduino学习笔记07】模拟信号的输入与输出 analogRead() analogWrite() map() constrain()

    模拟信号:Arduino中的模拟信号就是0v~5v的连续的电压值 数字信号:Arduino中的数字信号就是高电平(5V)或者低电平(0V),是两个离散的值 模拟信号->数字信号:ADC(模数转换 ...

随机推荐

  1. AVR单片机教程——EasyElectronics Library v1.3手册

    bit.h delay.h pin.h wave.h pwm.h tone.h adc.h button.h switch.h rotary.h pot.h ldr.h led.h rgbw.h se ...

  2. 【JVM】3、jvm参数和main方法参数

    在实际应用中,我们经常会使用一些额外的参数定义不通的环境下jvm的启动设置 特别是springCloud的项目,因为yml配置文件的问题,如果我们要做负载的话,会同时启动一个jar当做2个服务 那么这 ...

  3. Fiddler的使用总结

    关于Fiddler的使用过程中的总结: 1. 配置手机抓包的过程,以后再补充 2.使用Fiddler发送请求 1) 第一步 抓取接口,获取请求方式,以及请求参数  2) 第二步 请求接口 点击Exec ...

  4. Linux文件比对,批量复制

    --背景 工作中突然有一天文件服务器空间满了,导致文件存不进去,立马换了另外一台服务器作为文件服务器,将服务器挂载上去,原来的服务器修复之后需要重新换回来,但是需要将临时使用的服务器内的文件迁移至原文 ...

  5. 勒索病毒,华为/H3C三层交换机/路由器用ACL访问控制实现端口禁用

    前不久勒索病毒横行,很多人都纷纷中招,从公司到个人,损失相当惨重.有些公司在互联网入口上做了控制,但是这样并非完全,万一有人把中了毒的U盘插入网内设备上呢?那我们的内网中很有可能集体中招(打过相关补丁 ...

  6. 解决C#调用COM组件异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT)的错误

    最近C#调用COM时,遇到了异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT)的错误 后面找了一下,发现是在线程里调用COM组件引起的. C++调用COM时,会调用 ...

  7. FORM表单 onclick()与onsubmit()

    FORM表单中onclick().submit()与onsubmit()的问题 最近遇到一次处理form数据的过滤,采用了button的onclick事件来检查,发现return false后表单仍然 ...

  8. tf.concat的用法

    import numpy as npimport tensorflow as tfsess=tf.Session()a=np.zeros((1,2,3,4))b=np.ones((1,2,3,4))c ...

  9. visual studio 2015 开发时常见问题的解决方案

    1.visual studio 2015 用printf函数打印时来不及看结果窗口就关闭 方案一 在所写的代码后面,加上system("PAUSE"); 如下:

  10. js实现输入密码之延迟星号和点击按钮显示或隐藏

    缘由 手机打开segmentfalut时,长时间不登陆了,提示要重新登陆,输入的过程中看到输入密码时,延迟后再变成密文,很好奇,所以捣鼓了一下.本文实现了两种密码展示 代码实现 1 先明后密 js实现 ...