Hi, I hope I can describe my issue clearly enough…
I have a Pixy2 connected to Arduino Uno through ICSP header and am successfully driving a robotic cart.
To enhance the user feedback of the cart, I want to display certain output on a SSD1306 OLED display connected to the Uno through the I2C - SCL/SDA pins.
I had this all working and added the OLED as a later enhancement and I have struggled to get the OLED to initialise. I have broken the code down to the below example for simplicity.
Note:
- 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.
Any help would be greatly appreciated.
Sample code is…
#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...
}