Buy the components
arduino-debug.ino
#define DEBUG // Comment to turn off debug statements #include "DebugUtils.h" void setup() { pinMode(LED_BUILTIN, OUTPUT); #ifdef DEBUG SerialUSB.begin(9600); while (!SerialUSB) { } delay(100); #endif DEBUG_PRINT("Start blinking"); } void loop() { DEBUG_PRINT("HIGH"); digitalWrite(LED_BUILTIN, HIGH); delay(500); DEBUG_PRINT("LOW"); digitalWrite(LED_BUILTIN, LOW); delay(500); }
BOARD?=arduino:samd:mzero_bl PORT := $(shell ls /dev/cu.usbmodem*) BUILD=build .PHONY: default lint all flash clean default: lint all flash clean lint: cpplint --extensions=ino --filter=-legal/copyright *.ino all: arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./ flash: arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD) clean: rm -r build
A photo of the actual setup.
Serial output from the firmware.
Some patterns for toggling on and off debug print messages in Arduino firmware with #ifdef and a header file DebugUtils.h.
#ifdef
DebugUtils.h