Simple motion sensor

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_SSD1306.h>

int ledPin = D7;
int inputPin = D0;
bool available;
int motionCounter = 0;
#define OLED_DC D3
#define OLED_CS D4
#define OLED_RESET D5
Adafruit_SSD1306 display(OLED_DC,OLED_CS,OLED_RESET);
int x, minX;

void setup() 
    pinMode(ledPin, OUTPUT);
    pinMode(inputPin, INPUT);
    display.setTextSize (7);
    x = display.width();
    minX = -1500;

void loop() 
    if(digitalRead(inputPin) == HIGH)
        digitalWrite(ledPin, HIGH);
       // display.clearDisplay();
        display.print(" Hello there ");
        digitalWrite(ledPin, LOW);


Could someone help me as to why this is not printing.

Because you need to call display.display() when you are done feeding data into the local screenbuffer in RAM.

That’s why all the library examples do call that function all over the place :wink:


I made some changes and it still won’t print :roll_eyes:

try something like changing to: display.setCursor(1,1);
instead of display.setCursor(x/2,7);



hello, I’m very new to this, but I just got my featherwing oled working in a basic mode. Are you including the “oled-wing-adafruit.h” program from the library? It works, just press A button after you load it. Hope this helps.

Also, here is where I found the docs to get mine going…

I don’t know if @Dsradley5 is using the OLED Featherwing.

@Dsradley5 are you using the OLED Featherwing or a different OLED display?

What exact display are you using?
How have you wired the display?
Have you set it for SPI use?
How do you supply the signal to your input pin?
Is D7 LED going on as expected?
Does any of the Adafruit_SSD1306 samples work?

I am using a Serial OLED Screen 0.96”
Wired: D0-D0, D1-D1, RES-D2, DC-D3, CS-D4, VCC-3V3, GND-GND.
Yes, the LED is working properly.
I do not know the answer to the other questions.

This does not fit the code.
With this instruction Adafruit_SSD1306 display(OLED_DC,OLED_CS,OLED_RESET); you are telling the library to use SPI and consequently you don’t use the I2C pins D0/D1 on the controller but the SPI pins A4 (MISO) & A5 (MOSI) and you need to connet the CLK pin to A3 (SCK) - also your code has #define OLED_RESET D5 yet you wire RES-D2 :confused:

This doesn’t really qualify as a sufficient answer to

There are several different versions of that with different pin designations and some of them even have solder jumpers to select I2C or SPI.

1 Like

Here is a picture of my screen. I have adjusted the wires.

A view of the flip side of the screen would be good too.

See, there you are.
In the top left corner you have a legend that tells you how the solder jumpers of your display need to be set for what interface mode.
Since yours is set for 4-wire SPI, you need to wire it exactly for that and use the respective library constructor.

This post should give you the correct wiring


I continue to get an Error.

You should not include Adafruit_GFX since the Adafruit_SSD1306 library already brings its own verison of that library and hence you get multiple declarations.

However, you didn’t get that error before and hadn’t included that library in your previous versions, so that should have been some hint :wink:
So not …

… but rather: “I have changed something and now I get this error”

Oh crap. That’s true. That fixed the error but the screen still isn’t saying anything.

How are you wired now?
Can you post some updated (hi-res) photo to see the actual wiring?
And the most recent code?

1 Like