How do you debug Arduino code running on Arduino hardware?

user122299 picture user122299 · Aug 29, 2011 · Viewed 65.5k times · Source

Is there a way to set source-level breakpoints, run the code on actual hardware, and be able to inspect variables and continue?

Answer

Visual Micro picture Visual Micro · Apr 14, 2013

The Visual Micro plugin for Microsoft Visual Studio 2015 Community Edition (free) provides a USB debugger for Arduino. It allows you to do exactly as you describe. (Don't forget to click to install C++ during IDE install)

The debugger supports serial, RF, Bluetooth and some Wi-Fi. It enables the values of variables to be watched or update while the Arduino runs. Chart and data/pin visualizations along with watch, trace, break are included.

Enter image description here

News: January 2016 also includes release of a GDB debugger for the Arduino Zero. As with the Serial/Bluetooth debugger, the GDB version supports ino/cpp source code, but additionally supports debug of Arduino core and libraries. It supports many features such as: step over, step out, step instruction or source line, memory, registers, locals, watch, live expressions, and stack trace.