Skip to content

Zero SAMD, not work using 0 & 1 pin #825

Open

Description

@geva-elettronica

On Arduino Zero, not work using 0 & 1 pin.

Work using A0, 2.

`#include <FastLED.h>
#define LED_PIN 1 // A0 & 2 work well
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS+100];

void setup()
{
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
pinMode(LED_PIN, OUTPUT);
}

void loop()
{

digitalWrite(LED_PIN, HIGH); // This work
delay(100);
digitalWrite(LED_PIN, LOW); // This work
delay(100);
FastLED.show(); // This not work
}`

Activity

  1. geva-elettronica commented on Dec 19, 2019

    @geva-elettronica
    Author

    Now not work
    0, 1, (Serial1)
    2,
    25, 26, (Serial)
    44, 45 (SWCLK, SWDIO)

  2. added
    type: bug
    platform: samd
    area: core
    status: stale
    status: triage
    on Apr 16, 2026
  3. added
    deferred
    on Aug 1, 2026
  4. zackees commented on Aug 1, 2026

    @zackees
    Member

    Deferred by automated triage: Concrete, likely-real pin-map bug found, but not fixable without hardware or the Arduino variant file. FastLED's two Arduino-Zero-pinout maps in src/platforms/arm/d21/fastpin_arm_d21.h DISAGREE on pins 0 and 1: ARDUINO_SAMD_ZERO (line 271) has _FL_DEFPIN(0,10,0); _FL_DEFPIN(1,11,0) i.e. 0->PA10, 1->PA11, while ARDUINO_SEEED_ZERO (line 124) has _FL_DEFPIN(0,11,0); _FL_DEFPIN(1,10,0) i.e. 0->PA11, 1->PA10 -- exactly swapped. The Seeed Zero is Zero-pinout-compatible so both cannot be right. This matches the report precisely: digitalWrite(1,...) works while FastLED.show() does not, because digitalWrite uses the Arduino core's map and FastLED uses its own -- if they disagree, the two calls drive DIFFERENT physical pads, which is exactly the reported symptom. They also disagree on pins 2 and 4 (SAMD_ZERO 2->PA08/4->PA14 vs SEEED_ZERO 2->PA14/4->PA08). NOT FIXED HERE deliberately, same standard applied on #736: no Arduino SAMD core is installed locally so the authoritative variant.cpp could not be consulted, there is no Arduino Zero in CI, and guessing wrong would break pins 0/1 for every Zero user rather than merely leaving them broken. Contributor needs: read pin 0/1/2/4 port+bit out of the Arduino SAMD variant for arduino_zero, correct whichever map is wrong, and verify on hardware. Separate note on the follow-up comment listing 44,45 (SWCLK/SWDIO): MAX_PIN is 42 in that block, so those fail the validpin() static_assert at COMPILE time rather than failing silently -- a different failure mode from 0/1. Pins 25/26 (USB Serial) and 0/1 (Serial1) also have peripheral mux active by default on the Zero, which is a plausible second contributor worth checking after the map is corrected.

  5. zackees commented on Aug 1, 2026

    @zackees
    Member

    Marking deferred — found a concrete and probably-causal bug, but I can't responsibly fix it without hardware.

    The finding

    src/platforms/arm/d21/fastpin_arm_d21.h contains two maps for the Arduino-Zero pinout, and they disagree on pins 0 and 1:

    #elif defined(ARDUINO_SAMD_ZERO)      // line 271
    _FL_DEFPIN( 0,10,0); _FL_DEFPIN( 1,11,0);   // 0 -> PA10, 1 -> PA11
    
    #elif defined(ARDUINO_SEEED_ZERO)     // line 124
    _FL_DEFPIN( 0,11,0); _FL_DEFPIN( 1,10,0);   // 0 -> PA11, 1 -> PA10

    Exactly swapped. The Seeed Zero is Zero-pinout-compatible, so both cannot be correct. They also disagree on pins 2 and 4 (SAMD_ZERO 2→PA08 / 4→PA14 versus SEEED_ZERO 2→PA14 / 4→PA08).

    Why this explains your report

    Your sketch showed the tell without either of us realising it:

    digitalWrite(LED_PIN, HIGH);  // This work
    FastLED.show();               // This not work

    digitalWrite() uses the Arduino core's pin table. FastLED uses its own compile-time table, because it writes GPIO registers directly for speed. If the two tables disagree for a pin, those two lines drive different physical pads — the LED on your header sees the digitalWrite and never sees FastLED's output. That is precisely the behaviour you described, and it's what a swapped entry produces.

    Why I'm not just fixing it

    Same standard I applied on #736: no Arduino SAMD core is installed here, so I can't consult the authoritative variant.cpp to determine which of the two maps is right — and there's no Arduino Zero in CI to catch a wrong guess. Getting it backwards would break pins 0/1 for every Zero user rather than leaving them broken for some.

    For anyone with a Zero, this is a small and well-scoped fix: read the port and bit for pins 0, 1, 2 and 4 out of the Arduino SAMD variant for arduino_zero, correct whichever block is wrong, and confirm on hardware.

    On your follow-up list

    @geva-elettronica listed 0, 1, 2, 25, 26, 44, 45. Those aren't all the same failure:

    • 44, 45 (SWCLK/SWDIO) — MAX_PIN is 42 in that block, so these fail the validpin() static_assert at compile time. If they appeared to fail silently, something else was going on.
    • 0/1 (Serial1) and 25/26 (USB Serial) — these have peripheral mux active by default on the Zero, so the SERCOM owns the pad and direct GPIO writes may not reach it. That's a plausible second contributor, worth re-checking once the map is corrected.

    Deferred rather than closed so it stays visible with the diagnosis attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coredeferredplatform: samdstatus: stalestatus: triagetype: bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions