I suspect you cannot stop DMA once you have started it, so make all the DMA code function only if LED_BUILTIN is high. Paul