Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: struggling to communicate with ws2812

  1. #1

    struggling to communicate with ws2812

    Click image for larger version. 

Name:	IMG_1917.jpg 
Views:	18 
Size:	120.5 KB 
ID:	26483

    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:
    #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();; // Initialize all pixels to 'off'
    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 );;
        // Show the leds
        // 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:
    #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() { 
    void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
    void loop() { 
      static uint8_t hue = 0;
      // 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; 
        // 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.

  2. #2
    I think I missed grounding the IC, but just fixed that and no change.

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    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.


  4. #4
    Senior Member
    Join Date
    Apr 2021
    Cambridgeshire, UK
    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...

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    What happens if you try File > Examples > WS2812Serial > BasicTest, of course with the pin number edited to 10. Does that work?

  6. #6
    Thanks. You were right it was software.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts