Xiao using FastLED to control ws2812b

Hi everyone,

I tried the FastLED blink example (that tries to turn on and off the 1st LED on ws2812b) on the Xiao but the LED was not blinking. The same circuit setup and program works on an Arduino uno. Any idea? Thanks.

Setup like this:

  1. Xiao pin D3 as data pin connected to DIn on the ws2812b with a 330ohm resister in between.
  2. Xiao connected to PC thru type-c USB.
  3. ws2812b 5V power by an external power supply.

Cheers,
K

1 Like

Input logic has to be VCC -.5V/+5V. Since you are supplying 5V vcc to the strip the Xiao’s logic voltage of 3.3v would not be recognized by the LED. The reason it works with the Arduino Uno is the Arduino Uno has 5v logic pins. This setup should work but you would need to reduce the power voltage supplied to the strip down to around 3.8V or lower. Example would be using a LiPo battery rated at 3.7V.

Hope this makes sense.

1 Like

Thanks. I will try it out.

FastLED.h doesn`t support SAMD21 CPU.

This is not my original work but thought it may help someone if they wanted to use FastLED.

To get FastLED working you need to verify you are have the latest update to both the seeeduino boards as well as the FastLED library.

After verifying you have the most up to date versions of both.

Navigate into the FastLED library on your computer. Typically in C:\users<user name>\documents\arduino\libraries

you will want to navigate in the FastLED folder into the platforms then arm, then into d21, then edit the file called “fastpin_arm_d21”

Scroll down to around line 100 and paste this, and save.

#elif defined(SEEED_XIAO_M0)

#define MAX_PIN 10

_FL_DEFPIN( 0, 2,0); _FL_DEFPIN( 1, 4,0); _FL_DEFPIN( 2,10,0); _FL_DEFPIN( 3,11,0);

_FL_DEFPIN( 4, 8,0); _FL_DEFPIN( 5, 9,0); _FL_DEFPIN( 6, 8,1); _FL_DEFPIN( 7, 9,1);

_FL_DEFPIN( 8, 7,0); _FL_DEFPIN( 9, 5,0); _FL_DEFPIN(10, 6,0);

#define SPI_DATA 9

#define SPI_CLOCK 8

#define HAS_HARDWARE_PIN_SUPPORT 1

Seeeduino xiao fastled|690x261

Again this is not my work on the pin assignments. And they technically should be included in the latest version of FastLED but for some reason the master files haven’t had the modification as of this writing.

2 Likes

I don’t quite understand. Currently, FastLED is used in XIAO. Is there any problem?

So checking further into it today it appears if you use the library manager in the ArduinoIDE to download the FastLED library even though you tell it to download the latest version it does not contain the pin structure for the xiao. If the FastLED library is downloaded from github directly there appears to be no problem.

Sorry for the confusion.

1 Like

I’m sorry but do you mean if I download the latest FastLED library from github it should work on the xiao that it has nothing to do with the 3.3V vs 5V I/O difference? Thanks again.

Thank you! I’ve been battling with this and you’ve just solved my issue.

I can confirm: the signal voltage is not an issue, the lacking pin assignments is.

I’m new to this kind of thing. I’ve done the correction and uploaded the code. Should my wiring be LED gnd to Xiao gnd, LED 5V in to Xiao VCC, LED data in to Xiao pin 10 (as defined in my sketch code)?

Thank you @ssbirkenfeld for the pin structure fix; that solved the main issue I had (getting it to turn on at all). I have Seeeduino running the demo reel on an LED strip. It turns on and operates but the light changes are not smooth at all. This is not my first time running the demo reel so I know what its supposed to look like and it is very jittery.

Any ideas?

rough image of the build below:

Hello Seeed,

Made changes to FastLED library as given in the excellent detail by ssbirkenfield on Sep '20.

XIAO SAM 21D now working 79 LEDS using code marked
“WS2812B_FastLED_R_G_59_241220.ino”
posted herewith below.

But when the code from
File > Examples > FastLED > ColorPalette

is run the result does not work.

The Colorpalette code worked before the changes were made to the
FastLED library but now does not work.

Thanks.

Allen Pitts
Dallas TX

++++ WS2812b Code from Circuit Geeks +++++

//from How to Control WS2812B Addressable RGB LEDs using Arduino

#include <FastLED.h>

#define DATA_PIN 3

#define NUM_LEDS 79

#define BRIGHTNESS 64

#define LED_TYPE WS2812B

#define COLOR_ORDER GRB

// Define the array of leds

CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100

void setup() {

FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

FastLED.setBrightness(BRIGHTNESS);

}

void loop() {

// Turn the LED on

leds[0] = CRGB::Red;

leds[1] = CRGB::Green;

leds[2] = CRGB::Red;

leds[3] = CRGB::Green;

leds[4] = CRGB::Red;

leds[5] = CRGB::Green;

leds[6] = CRGB::Red;

leds[7] = CRGB::Green;

leds[8] = CRGB::Red;

leds[9] = CRGB::Green;

leds[10] = CRGB::Red;

leds[11] = CRGB::Green;

leds[12] = CRGB::Red;

leds[13] = CRGB::Green;

leds[14] = CRGB::Red;

leds[15] = CRGB::Green;

leds[16] = CRGB::Red;

leds[17] = CRGB::Green;

leds[18] = CRGB::Red;

leds[19] = CRGB::Green;

leds[20] = CRGB::Red;

leds[21] = CRGB::Green;

leds[22] = CRGB::Red;

leds[23] = CRGB::Green;

leds[24] = CRGB::Red;

leds[25] = CRGB::Green;

leds[26] = CRGB::Red;

leds[27] = CRGB::Green;

leds[28] = CRGB::Red;

leds[29] = CRGB::Green;

leds[30] = CRGB::Red;

leds[31] = CRGB::Green;

leds[32] = CRGB::Red;

leds[33] = CRGB::Green;

leds[34] = CRGB::Red;

leds[35] = CRGB::Green;

leds[36] = CRGB::Red;

leds[37] = CRGB::Green;

leds[38] = CRGB::Red;

leds[39] = CRGB::Green;

leds[40] = CRGB::Red;

leds[41] = CRGB::Green;

leds[42] = CRGB::Red;

leds[43] = CRGB::Green;

leds[44] = CRGB::Red;

leds[45] = CRGB::Green;

leds[46] = CRGB::Red;

leds[47] = CRGB::Green;

leds[48] = CRGB::Red;

leds[49] = CRGB::Green;

leds[50] = CRGB::Red;

leds[51] = CRGB::Green;

leds[52] = CRGB::Red;

leds[53] = CRGB::Green;

leds[54] = CRGB::Red;

leds[55] = CRGB::Green;

leds[56] = CRGB::Red;

leds[57] = CRGB::Green;

leds[58] = CRGB::Red;

leds[59] = CRGB::Green;

leds[60] = CRGB::Red;

leds[61] = CRGB::Green;

leds[62] = CRGB::Red;

leds[63] = CRGB::Green;

leds[64] = CRGB::Red;

leds[65] = CRGB::Green;

leds[66] = CRGB::Red;

leds[67] = CRGB::Green;

leds[68] = CRGB::Red;

leds[69] = CRGB::Green;

leds[60] = CRGB::Red;

leds[71] = CRGB::Green;

leds[72] = CRGB::Red;

leds[73] = CRGB::Green;

leds[74] = CRGB::Red;

leds[75] = CRGB::Green;

leds[76] = CRGB::Red;

leds[77] = CRGB::Green;

leds[78] = CRGB::Red;

leds[79] = CRGB::Green;

FastLED.show();

delay(2000);

FastLED.clear();

FastLED.show(); // send the updated pixel colors to the WS2812B hardware.

delay(250); // off time

}

++++ end of WS2812b Code from Circuit Geeks +++++

Hi there,

Yes that will happen, as entry points to the lib change when additive changes are made.
Could you do us ALL a “Solid” and edit your post to use the CODE TAGS above “</>” just paste it in there. Effects the readability and thus the quality of help you will get.

HTH
GL :slight_smile: PJ :v:

1 Like