struggling to communicate with ws2812

jrraines

Well-known member
IMG_1917.jpg

I'm trying to make an infinity cube with a teensy 3.2 and a ws2812 string. If I use a mega I can light each pixel of the string, using fastLED. I am only able to get the first pixel to light with what I've done with the teensy3.2

The sketch I'm using on the teensy is:
Code:
#include <WS2812Serial.h>
const int numled = 105;
const int colorStep = 65536/numled; //several loops would benefit from this constant
const int led_pin = 10;       //Pin to connect LED ring data in
byte drawingMemory[numled*3];         //  3 bytes per LED
DMAMEM byte displayMemory[numled*12]; // 12 bytes per LED

WS2812Serial ring(numled, displayMemory, drawingMemory, led_pin, WS2812_RGB);
void setup() { 
  ring.begin();
  ring.show(); // Initialize all pixels to 'off'
  ring.setBrightness(84);
  delay(3000);
  Serial.begin(9600);
  pinMode(13,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  static uint32_t c,color = 0x0f0f00;
  // First slide the led in one direction
  for(int i = 0; i < numled; i++) {
   // digitalWrite(13,LOW);
    // Set the i'th led to red 
     ring.setPixelColor(c, 0xff0000 );
     ring.show();
     
     Serial.println(i);
    // Show the leds
     delay(200);
     digitalWrite(13,HIGH);
     delay(200);
    // now that we've shown the leds, reset the i'th led to black
     ring.setPixelColor(c, 0 );
  }

}

for what it's worth the Mega code is:
Code:
#include "FastLED.h"

// How many leds in your strip?
#define NUM_LEDS 105 

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define CLOCK_PIN 13

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() { 
  Serial.begin(57600);
  Serial.println("resetting");
  LEDS.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
  LEDS.setBrightness(84);
}
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }

void loop() { 
  static uint8_t hue = 0;
  //Serial.print("x");
  // First slide the led in one direction
  for(int i = 0; i < NUM_LEDS; i++) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show(); 
    delay(100);
    // now that we've shown the leds, reset the i'th led to black
    leds[i] = CRGB::Black;
  }
}

I presume my issue is electrical rather than software. The IC is a SN54AHCT125. On the mega I did not use a capacitor or resistor, just plugged into D6 and 5V and GND directly on the board.
 
Perhaps you should try the basic WS2812Serial example first to rule out any hardware issues.
You wiring seems OK, although good engineering practice is to connect unused pins to a defined level instead of leaving them floating.

Paul
 
Not familiar with that library, but you appear not to be iterating the LED number: your loop iterates i, but ring.setPixelColor() is using c, which you never touch after defining it...
 
What happens if you try File > Examples > WS2812Serial > BasicTest, of course with the pin number edited to 10. Does that work?
 
Back
Top