arduino+oled测试实验

本文档详细介绍了如何使用Arduino进行OLED显示实验,包括接线、下载必要的库、显示示例代码及可能出现的问题解决。实验中涉及了Adafruit SSD1306 Library和Adafruit GFX Library,通过I2C通信连接128x64的OLED屏幕,并展示了绘制像素、线条、矩形、圆形等图形的方法。
摘要由CSDN通过智能技术生成

一、连线

针脚说明

VCC   接3.3v电源

GND  接地(GND)

SCL   时钟线

SDA   数据线


接线图

二、下载测试代码

在上代码之前,先下载两个库分别是

Adafruit SSD1306 Library:

http://download.csdn.net/download/qq_24397253/9969004

Adafruit GFX Library:

http://download.csdn.net/download/qq_24397253/9967474

下载后把解压的文件放在 Arduino 安装目录里的 "libraries"

例如:C:\Program Files (x86)\Arduino\libraries



调出示例程序



或者复制以下代码,都是一样的:

[objc]  view plain   copy
  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 128x64 size display using I2C to communicate 
  8. 3 pins are required to interface (2 I2C and one reset) 
  9.  
  10. Adafruit invests time and resources providing this open source code,  
  11. please support Adafruit and open-source hardware by purchasing  
  12. products from Adafruit! 
  13.  
  14. Written by Limor Fried/Ladyada  for Adafruit Industries.   
  15. BSD license, check license.txt for more information 
  16. All text above, and the splash screen must be included in any redistribution 
  17. *********************************************************************/  
  18.   
  19. #include <SPI.h>  
  20. #include <Wire.h>  
  21. #include <Adafruit_GFX.h>  
  22. #include <Adafruit_SSD1306.h>  
  23.   
  24. #define OLED_RESET 4  
  25. Adafruit_SSD1306 display(OLED_RESET);  
  26.   
  27. #define NUMFLAKES 10  
  28. #define XPOS 0  
  29. #define YPOS 1  
  30. #define DELTAY 2  
  31.   
  32.   
  33. #define LOGO16_GLCD_HEIGHT 16   
  34. #define LOGO16_GLCD_WIDTH  16   
  35. static const unsigned char PROGMEM logo16_glcd_bmp[] =  
  36. { B00000000, B11000000,  
  37.   B00000001, B11000000,  
  38.   B00000001, B11000000,  
  39.   B00000011, B11100000,  
  40.   B11110011, B11100000,  
  41.   B11111110, B11111000,  
  42.   B01111110, B11111111,  
  43.   B00110011, B10011111,  
  44.   B00011111, B11111100,  
  45.   B00001101, B01110000,  
  46.   B00011011, B10100000,  
  47.   B00111111, B11100000,  
  48.   B00111111, B11110000,  
  49.   B01111100, B11110000,  
  50.   B01110000, B01110000,  
  51.   B000000
  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值