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

Thread: Teensy 3.2 and WS2812B NOT WORKING?

  1. #1
    Junior Member
    Join Date
    Feb 2020
    Posts
    10

    Teensy 3.2 and WS2812B NOT WORKING?

    Can anyone help me get this code working? This code is working on the Arduino but not transitioning to the Teensy.
    I am trying to illuminate 3 LEDs on the WS2812B with my Teensy 3.2.

    Code:
    #include <Adafruit_NeoPixel.h>
    
    #define LED_PIN    3
    #define LED_COUNT  3
    
    Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
    
    void colorWipe(uint32_t color, int wait) {
      for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
        strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
        strip.show();                          //  Update strip to match    
      }                    
    }
    
    void setup() {
    }
    
    void loop() {
      colorWipe(strip.Color(0,  255,   0), 0); // Green
    }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,118
    Are you sure that works on normal Arduino? I don't see how it could, since you're missing "strip.begin();" to initialize the library.

    I tested just now with a Teensy 3.2 and the missing line added.

    Click image for larger version. 

Name:	DSC_0725_web.jpg 
Views:	6 
Size:	160.4 KB 
ID:	19063

    Here's the full code I tested:

    Code:
    #include <Adafruit_NeoPixel.h>
    
    #define LED_PIN    3
    #define LED_COUNT  3
    
    Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
    
    void colorWipe(uint32_t color, int wait) {
      for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
        strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
        strip.show();                          //  Update strip to match    
      }                    
    }
    
    void setup() {
      strip.begin();
    }
    
    void loop() {
      colorWipe(strip.Color(0,  255,   0), 0); // Green
    }

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,118
    Also consider that some WS2812 LEDs (NeoPixel) do not work with 3.3V signals.

    But most newer ones do accept 3.3V, as do the very oldest ones.

  4. #4
    Junior Member
    Join Date
    Feb 2020
    Posts
    10
    I forgot to copy that line over to my Teensy sketch . All working now, thankssss

Posting Permissions

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