博文

目前显示的是标签为“debug”的博文

How to debug Arduino Nano 33 IoT code?

图片
The Arduino Nano 33 IoT ( ATSAMD21G18 , 3.3 V) is great for “real” debugging. Here’s a focused playbook just for this board. 1) Quick wins (native USB board) Select the right core/board: Boards Manager → Arduino SAMD Boards → Arduino Nano 33 IoT . USB gotcha: a bad sketch can “hide” the port. Double-tap RESET → bootloader mode (LED pulsing) → upload again. Serial init (with timeout): void setup () { Serial. begin ( 115200 ); unsigned long t0 = millis (); while (!Serial && ( millis ()-t0 < 1500 )) { } // don't hang forever Serial. println ( "Hello from Nano 33 IoT" ); } 3.3 V only. Don’t feed 5 V signals into pins. 2) Print-style debugging (fastest) Use Serial.print/println liberally. For periodic sanity: static uint32_t last; if ( millis () - last > 1000 ) { last = millis (); Serial. printf ( "t=%lu\n" , millis ()); } On SAMD, Serial is the USB CDC port; Serial1 is on D0/D1 if you need an extern...