Author Topic: NeoPixel library and pin names  (Read 12282 times)

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: NeoPixel library and pin names
« Reply #15 on: February 16, 2016, 04:06:46 am »
similar to the Particle devices and other ESP8266 devices - if you have a while() loop you need to periodically call delay() or Particle.process() to keep the cloud/wifi working during that.

emardee

  • Full Member
  • ***
  • Posts: 136
Re: NeoPixel library and pin names
« Reply #16 on: April 01, 2016, 04:44:57 am »
Great to see some discussions on Digital Pixel LED strips being controlled by OAK via various libraries.

I'm still waiting for my OAKs to arrive, but keen to start reading up on my options ready.

Does anyone know which of these libraries already support RGBW strips? (32bit per pixel instead of 24bit). I figure if my preferred library doesn't already support it, I could hopefully cannibalise it to work alright, but better to start with existing proper supported code if possible by choosing my library carefully at the start! (how do I pick?)

Is anyone here using any of these libraries with the Oak Level shifter shield?


Well looks like FastLED doesn't yet support RGBW strip, but it is on the radar for future development:
https://github.com/FastLED/FastLED/issues/106

NeoPixel and NeoMatrix support RGBW strips, so they look like the obvious starting point for now...

shiny

  • Newbie
  • *
  • Posts: 6
Re: NeoPixel library and pin names
« Reply #17 on: April 08, 2016, 06:57:52 pm »
This worked for me -- note the use of: esp8266_pinToGpio[NEOPIXEL_PIN]


#include <Adafruit_NeoPixel.h>
#define NEOPIXEL_PIN   6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      8

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, esp8266_pinToGpio[NEOPIXEL_PIN], NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode(NEOPIXEL_PIN, OUTPUT);
  digitalWrite(NEOPIXEL_PIN, LOW);
 
  //set up neopixel
  pixels.begin();
}

void loop() {
  delay(1000);

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  for(int i=0;i<NUMPIXELS;i++){
    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, 0, 255, 0); // Moderately bright green color.
    pixels.setBrightness(50);   
  }
  pixels.show(); // This sends the updated pixel color to the hardware.
}

DrJFM

  • Newbie
  • *
  • Posts: 30
Re: NeoPixel library and pin names
« Reply #18 on: April 11, 2016, 07:33:18 pm »
Just to Update this topic a bit.  Using Oak with 1.0 Firmware.  Loaded Arduino 1.6.8 on Windows 10 64 Bit machine.  Fought w DigiLED a bit till I discovered the pin remapping noted by cppetito.  I am using AJPowell's implementation of the workaround (see below) posted by cpetito http://digistump.com/board/index.php/topic,1984.msg8888.html#msg8888

I have the level shifter shield and it worked but was not necessary.  It has a nice 3 wire servo pin set for Oak Pin 7.  This maps to GPIO pin 13 on the Acorn module. You only need 5V, Ground and a digital pin output for the DigiLED and, by extension, for the strings of LEDs the Adafruit NeoPixel library will drive.  I got this working first on Pin 5 from the level shifter, since that seemed the most direct application of ajpowell's code from his GitHub collection (Thanks, AJ). While the shifter might be a wise choice for a multi light system, the Oak provides 5 V pins as VCC if driven by 5V via USB and the application worked fine without the level shifter.  Wired VCC, Ground and Oak pin 7 directly to the 5V, Ground and Pin 1 pin of my DigiLED shield with jumper wires. The 3.3 V max digital signal out to the DigiLED was more than enough to provide a binary stream to program that device. Don't try this non level shifter approach with input pins or if you are trying to drive a load, but as a digital signal or logic bit, don't always need to shift the level up in logic applications.  I didn't bother to change the GPIO pin number back to input after the NeoPixel library did its thing but should to keep pins low and have fewer positive voltage pins/headers unused. Now hopefully I will remember this possible numbering conflict for other possible apps.

So my (hopefully) useful additions: Besides Pin Oak Pins 1 and 5, Pin 7 works fine (by sending PIN 5, 4 and 13 to the NeoPixel Library). By extention, most any of the Acorn digital pins can be used.  There is a nice table of these mappings at the bottom of the pin out diagram that DigiStump published (and I ignored too long) 

   Oak Pin to ESP8266 GPIO Mapping
   Oak Pin    P0    P1    P2    P3    P4    P5    P6    P7    P8    P9    P10    P11
   GPIO        2       5      0     3     1     4     15    13    12    14     16     17
   
From <=pinout]http://digistump.com/wiki/oak/tutorials/pinout?s[]=pinout

  • Level Shifter worked w DigiLED but was not necessary. The colors were muted without shifter but logic worked. Same 5V source in w and w/o shift
  • Arduino IDE 1.6.8 has been working fine for me on Win 10.
  • Adafruit NeoPixel Library 1.0.4 needs the GPIO pin number sent to it and then use the corresponding Oak Pin number set to output

Now I have to try AJPowell's other examples and get the Particle cloud working for more than uploading...



Hi guys,

I was reading this with interest as I had tried to compile the example code that is given in the DigiLED tutorial and upload to one of my Oaks - it would compile, but the DigiiLED wouldn't change - with the additional info that @cppetito had found, I finally got the code working - the DigiLED has the option of working with Oak pin 1 (default) or Oak pin 5 - both options are covered in my updated code here (will update the tutorial shortly): https://github.com/ajpowell/OakSamples

I may refine the code a little - could easily perform the map in an array, so you specify the Oak pin, but it works out the GPIO port in code.
« Last Edit: April 12, 2016, 06:59:11 am by DrJFM »

defragster

  • Sr. Member
  • ****
  • Posts: 467
Re: NeoPixel library and pin names
« Reply #19 on: April 12, 2016, 04:19:34 pm »
I keep seeing cool Connectivity methods in various threads.  Starting one thread to track them might work but could get polluted quickly - it could become a WIKI section.  It occurred to me putting a unique string once per Thread where stuff works could at least allow a forum Search to work.
NeoPixel::OAK_CONNECT

micahwedemeyer

  • Newbie
  • *
  • Posts: 6
Re: NeoPixel library and pin names
« Reply #20 on: July 20, 2016, 08:31:14 am »
I got the Sparkfun 5v addressable strips (https://www.sparkfun.com/products/12025) working with FastLEDs on the Oak. A few notes:

  • I had to use FastLED master branch, not the official 3.1 release.
  • I am driving the LED strip with pin 3. That's the only pin where the pin number and GPIO match up exactly, according to this: http://digistump.com/wiki/oak/tutorials/pinout
  • I am running the FastLED "cylon" example on a 1m strip . Looks pretty sweet.
  • I am powering both the Oak and the strip in parallel with an external 5V regulated power supply. I've got the power supply hooked (via barrel jack) to a protoboard power/ground bus that then connects to the Vin and GND pins in the middle of the Oak. The LED strip is also connected (in parallel) to that power/ground bus. The plan is to allow the LED strip to draw as much current as it needs without pulling it through the Oak.

Finally, and I doubt this is Oak related, but when I wired in the resistor recommended here ( https://learn.sparkfun.com/tutorials/ws2812-breakout-hookup-guide/hardware-hookup ), it gave me a lot of problems. It seems like it was interfering with the data signal. The LEDs would come on, but were not following the correct color pattern. I tried 220Ohm like suggested and eventually  moved down to something like 47Ohm. I'm very new to this and maybe 47Ohm is worthless for the intended purpose, but anything higher than that caused issues.
« Last Edit: July 25, 2016, 07:55:43 am by micahwedemeyer »

emardee

  • Full Member
  • ***
  • Posts: 136
Re: NeoPixel library and pin names
« Reply #21 on: July 21, 2016, 01:08:02 am »
I'm presuming that because the data signal from the Oak is at 3.3v and the LEDs are expecting 5v, that too high a value of inline resistor causes the signal to not get through reliably. Someone else will be able to better explain if that is indeed the correct reason, and if so the maths behind it.

I haven't got round to trying mine Oaks with my neo-pixels yet, but glad to hear it is working without a level shifter attached. (I bought 2 of the level shifter shields from Digistump in case they were needed for controlling neo-pixels, so I can save them for a different project now).

Mike


Z69

  • Newbie
  • *
  • Posts: 28
Re: NeoPixel library and pin names
« Reply #22 on: July 21, 2016, 09:35:30 am »
Best bidirectional level shifter ever