# Simple motion sensor

**URL:** <https://community.particle.io/t/simple-motion-sensor/46682>\
**Category:** Troubleshooting\
**Created:** [January 1, 2019, 8:42pm UTC](https://community.particle.io/t/simple-motion-sensor/46682 "2019-01-01T20:42:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 1, 2019, 8:42pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/1 "2019-01-01T20:42:54Z")

</div>

[https://go.particle.io/shared\_apps/5c2bcfe977cc9f55fb000526](https://go.particle.io/shared_apps/5c2bcfe977cc9f55fb000526)

```auto
// 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.begin(SSD1306_SWITCHCAPVCC);
    display.setTextSize (7);
    display.setTextColor(WHITE);
    display.setTextWrap(false);
    x = display.width();
    minX = -1500;
}

void loop() 
{
    if(digitalRead(inputPin) == HIGH)
    {
        digitalWrite(ledPin, HIGH);
       // display.clearDisplay();
        display.setCursor(x/2,7);
        display.print(" Hello there ");
    }
    else
    {
        digitalWrite(ledPin, LOW);
    }
    delay(500);

}

```

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

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 1, 2019, 10:20pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/2 "2019-01-01T22:20:45Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 1, 2019, 11:53pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/3 "2019-01-01T23:53:20Z")

</div>

[https://go.particle.io/shared\_apps/5c2bfcb677cc9f55fb00090b](https://go.particle.io/shared_apps/5c2bfcb677cc9f55fb00090b)

I made some changes and it still won’t print 🙄

---

<div class="post-metadata">

**Author:** ![Rftop](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/rftop/32/16896_2.png) [@Rftop](https://community.particle.io/u/Rftop)\
**Post date:** [January 2, 2019, 1:08am UTC](https://community.particle.io/t/simple-motion-sensor/46682/4 "2019-01-02T01:08:58Z")

</div>

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

`

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 2, 2019, 2:11am UTC](https://community.particle.io/t/simple-motion-sensor/46682/5 "2019-01-02T02:11:15Z")

</div>

Nothing🤔

---

<div class="post-metadata">

**Author:** ![Ch2019](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Ch2019](https://community.particle.io/u/Ch2019)\
**Post date:** [January 2, 2019, 3:03am UTC](https://community.particle.io/t/simple-motion-sensor/46682/6 "2019-01-02T03:03:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ch2019](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@Ch2019](https://community.particle.io/u/Ch2019)\
**Post date:** [January 2, 2019, 3:09am UTC](https://community.particle.io/t/simple-motion-sensor/46682/7 "2019-01-02T03:09:13Z")

</div>

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

> **[rickkas7/oled-wing-adafruit](https://github.com/rickkas7/oled-wing-adafruit)**
>
> Driver for Adafruit feather wing with SSD1306 oled and buttons - rickkas7/oled-wing-adafruit

---

<div class="post-metadata">

**Author:** ![nrobinson2000](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/nrobinson2000/32/15624_2.png) [@nrobinson2000](https://community.particle.io/u/nrobinson2000)\
**Post date:** [January 2, 2019, 4:46am UTC](https://community.particle.io/t/simple-motion-sensor/46682/8 "2019-01-02T04:46:25Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 2, 2019, 8:47am UTC](https://community.particle.io/t/simple-motion-sensor/46682/9 "2019-01-02T08:47:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 2, 2019, 3:18pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/10 "2019-01-02T15:18:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 2, 2019, 3:35pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/11 "2019-01-02T15:35:38Z")

</div>

> [@Dsradley5](#):
>
> Wired: D0-D0, D1-D1, RES-D2, DC-D3, CS-D4, VCC-3V3, GND-GND.

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` 😕

> [@Dsradley5](#):
>
> I am using a Serial OLED Screen 0.96”

This doesn't really qualify as a sufficient answer to

> [@ScruffR](#):
>
> What _ **exact** _ display are you using?

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

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 2, 2019, 3:46pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/12 "2019-01-02T15:46:20Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/4/8/48b01cf4adcc64e7b5d8b5395bd1b57ddb7c10bc.jpg)  
Here is a picture of my screen. I have adjusted the wires.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 2, 2019, 3:49pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/13 "2019-01-02T15:49:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 2, 2019, 4:11pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/14 "2019-01-02T16:11:19Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/b/e/bed668b6fdd7f17d7f57cfb402d289f7fe7b6bbd.jpg)

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 2, 2019, 4:20pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/15 "2019-01-02T16:20:42Z")

</div>

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

> [@Adafruit SSD1306 \[SOLVED\]](https://community.particle.io/t/adafruit-ssd1306-solved/15175/8):
>
> The Adafruit\_SSD1306 library that can be found in Particle Build (Web IDE) does work for the display coming with the kit. If building in Particle Build (Web IDE) you need to change the includes in the demos to // e.g. ssd1306-128x64-spi.ino #include "Adafruit\_SSD1306/Adafruit\_GFX.h" #include "Adafruit\_SSD1306/Adafruit\_SSD1306.h" If building with Particle Dev or CLI just leave them as they are For all IDEs do the wiring like this // use hardware SPI // OLED\_D0 -\> A3 (SPI CLK) // OLED\_D1 -\> …

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 2, 2019, 9:57pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/16 "2019-01-02T21:57:55Z")

</div>

[https://go.particle.io/shared\_apps/5c2d32d674879deb66000918](https://go.particle.io/shared_apps/5c2d32d674879deb66000918)

I continue to get an Error.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 2, 2019, 10:16pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/17 "2019-01-02T22:16:42Z")

</div>

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 😉  
So not ...

> [@Dsradley5](#):
>
> I continue to get an Error.

... but rather: _"I have changed something and now I get this error"_

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 2, 2019, 10:39pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/18 "2019-01-02T22:39:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [January 3, 2019, 10:19am UTC](https://community.particle.io/t/simple-motion-sensor/46682/19 "2019-01-03T10:19:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dsradley5](https://avatars.discourse-cdn.com/v4/letter/d/858c86/32.png) [@Dsradley5](https://community.particle.io/u/Dsradley5)\
**Post date:** [January 3, 2019, 2:28pm UTC](https://community.particle.io/t/simple-motion-sensor/46682/20 "2019-01-03T14:28:52Z")

</div>

[https://go.particle.io/shared\_apps/5c2e1b8374879da02d00112a](https://go.particle.io/shared_apps/5c2e1b8374879da02d00112a)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/7/1/71ede066c0663cabdfd8089e935f602ee4671aa5.jpg)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/particle/original/3X/1/7/1741d9277994fb233f0a240b119a38f867966f9d.jpg)

[Next page](https://community.particle.io/t/simple-motion-sensor/46682.md?page=2)
