Hi Edward,
Yes it is very odd. I have tried re-ordering the code sequence but with no success.
I have made one further revelation as well. I have simplified the problem in the code shared below with the following notes:
I have changed the I2C address for the OLED to 0x3D (from the default 0x3C) but this didn’t fix the issue.
If I uncomment the Servo declaration (//Servo leftServo;) then the OLED fails to initialise.
Sample code is…
If I leave the Servo line in the code drops to:
Serial.println(F(“SSD1306 allocation failed”));
If I leave the Servo line out then the OLED initialises correctly (but then of course I lose my servos :-))
#include <Arduino.h>
#include <Servo.h>
#include <SPI.h>
#include <Pixy2.h>
#include <PIDLoop.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSansOblique9pt7b.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define I2C_ADDRESS 0x3D // I2C address for OLED display (or 0x3C)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
Pixy2 pixy;
//Servo leftServo;
void setup()
{
Serial.begin(9600);
Serial.println(F("Initialising SSD1306"));
if (!display.begin(SSD1306_SWITCHCAPVCC, I2C_ADDRESS))
{
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
Serial.println(F("SSD1306 allocation SUCCES"));
// some stuff - happy to share...
}
void loop()
{
// some stuff - happy to share...
}