I'm trying to connect an OLED display to the Arduino M0. I got the code example (ssd1306_128x64_i2c) from the Adafruit SSD1306 library I downloaded.
Video showing at 8:14 how it should look
However, when I upload the code to the board most of the display just lights up with no motion. It's only in the bottom that you can see the program is running, showing part of the different shapes.
After I uploaded it the first time I didn't change anything but now the compiler gives an error message saying that one display setting must be specified in SSD1306.h
I've tried setting the display size in the library header file which looks like this:
Displays
-----------------------------------------------------------------------
The driver is used in multiple displays (128x64, 128x32, etc.).
Select the appropriate display below to create an appropriately
sized framebuffer, etc.
SSD1306_128_64 128x64 pixel display
SSD1306_128_32 128x32 pixel display
SSD1306_96_16
#define SSD1306_128_64
//#define SSD1306_128_32
//#define SSD1306_96_16
But the same error message appears in the compiler.
Does anybody know how I can fix this?
Thank you.
-
if your size is wrong but something shows up, it's not IIC, it's the screen settings.dandavis– dandavis2017年11月08日 21:40:10 +00:00Commented Nov 8, 2017 at 21:40
-
The Adafruit library works with the Adafruit oled display. There are about four or five different oled types. If you don't have a Adafruit oled, then you could try a few different modes of the U8g2 library, or buy a Adafruit oled.Jot– Jot2017年11月08日 22:09:31 +00:00Commented Nov 8, 2017 at 22:09
1 Answer 1
That header part should look like this (notice the comment starts and ends):
/*=========================================================================
SSD1306 Displays
-----------------------------------------------------------------------
The driver is used in multiple displays (128x64, 128x32, etc.).
Select the appropriate display below to create an appropriately
sized framebuffer, etc.
SSD1306_128_64 128x64 pixel display
SSD1306_128_32 128x32 pixel display
SSD1306_96_16
-----------------------------------------------------------------------*/
#define SSD1306_128_64
// #define SSD1306_128_32
// #define SSD1306_96_16
/*=========================================================================*/
If it compiles but doesn't work try to replace the I2C address of Adafruits 128x64 module (0x3D) by the address often used in Chinese modules (0x3C):
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
to
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
If that doesn't work, use an I2C scanner to find the address of the connected module.
-
Thank you Pylon. I reloaded the library and the error message regarding choosing the display stopped appearing. However, I think there migt be something wrong with the board as my computer can't connect to it. But your answer solved the problem. :)bitsnbytes– bitsnbytes2017年11月09日 09:21:00 +00:00Commented Nov 9, 2017 at 9:21