user206: Though an emulator is quite useful for debugging code that has no side effects, most real-world applications include some circuitry besides the Arduino. If a microcontroller on an Arduino had a JTAG interface, it would be pretty straight-forward, but what if it's e.g. an Arduino Uno?

user4169: This might not be right for you, but the Visual Micro plugin for Atmel Studio and Visual Studio has a USB debugger which only uses Arduino code.
In the background the debugger uses Serial which might affect some time-sensitive applications.


user349: The Arduino Uno uses the Atmel Atmega328p microcontroller, which only has one debug option, DebugWire.  There are a few tools that can work with it, but the least expensive and most commonly available is the AVR Dragon.
You can use AVR Studio 6 for this.  You can use the .elf file file produced during the Arduino build process directly, but setting up the debugger is a little easier if you port the Arduino program to the AVR Studio.  It's not difficult, but there are a lot of little pieces to deal with.  There are guides online to help you through this.

206: <p>Though an emulator is quite useful for debugging code that has no side effects, most real-world applications include some circuitry besides the Arduino. If a microcontroller on an Arduino had a JTAG interface, it would be pretty straight-forward, but what if it's e.g. an Arduino Uno?</p>
 4169: <p>This might not be right for you, but the <a href="http://www.visualmicro.com/" rel="nofollow noreferrer">Visual Micro</a> plugin for Atmel Studio and Visual Studio has a <a href="http://www.visualmicro.com/page/Debugging-for-Arduino.aspx" rel="nofollow noreferrer">USB debugger</a> which only uses Arduino code.</p>

<p>In the background the debugger uses Serial which might affect some time-sensitive applications.</p>

<p><img src="https://i.stack.imgur.com/6Mqkn.png" alt="Enter image description here"></p>
 349: <p>The Arduino Uno uses the Atmel Atmega328p microcontroller, which only has one debug option, DebugWire.  There are a few tools that can work with it, but the least expensive and most commonly available is the <a href="http://www.atmel.com/tools/AVRDRAGON.aspx">AVR Dragon</a>.</p>

<p>You can use AVR Studio 6 for this.  You can use the <code>.elf</code> file file produced during the Arduino build process directly, but setting up the debugger is a little easier if you port the Arduino program to the AVR Studio.  It's not difficult, but there are a lot of little pieces to deal with.  There are guides online to help you through this.</p>
