Hi Everyone,
I've got a Flora that is setup to output on an OLED display, as well as a NeoPixel Ring; but it can only output one or the other:
Parts:
Neopixel 24 Ring: https://www.adafruit.com/products/1586
128x64 SPI OLED Display: https://www.adafruit.com/product/661
The pins are setup as follows:
Ring GND -> Flora GND
Ring 5V -> Flora VBatt
Ring Data In -> Flora D12
Flora is USB powered for now
OLED Vin -> Flora 3.3V
OLED GND -> Flora GND
OLED DATA -> Flora D6
OLED CLK -> Flora D3
OLED DC -> Flora D10
OLED CS -> Flora D1
OLED RESET -> Flora D2
I can run the ssd1306_128x32_spi sketch no problem; and I can run the strandtest sketch, no problem; but I can't get both to output at the same time if I combine the sketches into one. Depending on which one I initialize first in the sketch, the other will remain dark. The code continues to run as if the OLED or ring are displaying as normal.
Hypothesis: Insufficient power or memory on the flora. Possibly a conflict with the pins I'm using. Or, worst case, my code.
Thanks!!
SPI OLED and NeoPixel Ring Conflict
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: SPI OLED and NeoPixel Ring Conflict
It could be a memory issue. Could you post your code ?
Please use the code button "</>" or
Please use the code button "</>" or
Code: Select all
tags when posting code to the forums.
- thechill
- Posts: 10
- Joined: Mon Aug 11, 2014 7:52 pm
Re: SPI OLED and NeoPixel Ring Conflict
Code below. Again, I can run the sample codes independently (strandtest, ssd1306_128x32_spi) just fine on the same setup.
Note that using the below, the OLED works fine, but the LED ring won't respond to any setpixelcolor commands. I tried multiple pixel addresses (0-23) and RGB codes. Interestingly, if I run a piece of LED ring code beforehand (i.e., set the LED ring to all red), it retains this in memory and continues to show the red LED ring pattern even when I run the code below after it. That makes me think it's a memory issue rather than a power issue.
Note that using the below, the OLED works fine, but the LED ring won't respond to any setpixelcolor commands. I tried multiple pixel addresses (0-23) and RGB codes. Interestingly, if I run a piece of LED ring code beforehand (i.e., set the LED ring to all red), it retains this in memory and continues to show the red LED ring pattern even when I run the code below after it. That makes me think it's a memory issue rather than a power issue.
Code: Select all
// SPI OLED Reqs
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_MOSI 6
#define OLED_CLK 3
#define OLED_DC 10
#define OLED_CS 1
#define OLED_RESET 2
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
// NeoPixel Ring Reqs
#include <Adafruit_NeoPixel.h>
#define PIN 12
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);
// SETUP
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
// Clear the buffer.
// The following won't work
strip.setPixelColor(1, strip.Color(255,255,0));
strip.show();
delay(100);
}
// MAIN
void loop() {
// Display on the OLED, this works
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("This works, but my LED doesn't");
display.display();
delay(100);
// And this won't work here either
strip.setPixelColor(2, strip.Color(0,255,0));
strip.show();
delay(100);
display.clearDisplay();
}
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: SPI OLED and NeoPixel Ring Conflict
You might take a look at this on Arduino memory management
- thechill
- Posts: 10
- Joined: Mon Aug 11, 2014 7:52 pm
Re: SPI OLED and NeoPixel Ring Conflict
Well, my sketch compiles at 15K, well under the 28K flash limit with a bootloader. And the SRAM utilization according to this shouldn't be more than 1.1K, which is well under the 2.5K limit...
Not sure what it could be then...
Not sure what it could be then...
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: SPI OLED and NeoPixel Ring Conflict
The compiler's estimate of SRAM usage isn't a very useful number. You want to include the freeRam function from the tutorial, and call it at the end of setup()
- adafruit2
- Posts: 22200
- Joined: Fri Mar 11, 2005 7:36 pm
Re: SPI OLED and NeoPixel Ring Conflict
Hmm that is odd. But not sure what it could be...it *might* be RAM but 24 pixels isn't very much. Do you have a logic analyzer or scope? would be useful to see if it even sends the data out the neopixel pin
- thechill
- Posts: 10
- Joined: Mon Aug 11, 2014 7:52 pm
Re: SPI OLED and NeoPixel Ring Conflict
I get freeRam() reading back end of setup at 1432.
I unfortunately don't have a logic analyzer or a scope; I could probably get a general "something is happening" on my multimeter, but that's it.
Is this something you guys have seen before?
I unfortunately don't have a logic analyzer or a scope; I could probably get a general "something is happening" on my multimeter, but that's it.
Is this something you guys have seen before?
- pburgess
- Posts: 4161
- Joined: Sun Oct 26, 2008 2:29 am
Re: SPI OLED and NeoPixel Ring Conflict
Just missing a strip.begin() in the setup() function, that should take care of it.
- thechill
- Posts: 10
- Joined: Mon Aug 11, 2014 7:52 pm
Re: SPI OLED and NeoPixel Ring Conflict
: ( Embarrassing.
Thank you!!
Thank you!!
Please be positive and constructive with your questions and comments.