Go Down

Topic: First steps debugging (Read 1 time) previous topic - next topic

akis_t

Hello,

This is a very very basic question about debugging

I very recently got a couple of Arduino Nanos from ebay and basically the Nano is a tiny board with an Atmega328 as well as a USB interface. You plug the Nano to the PC/laptop and it uses the USB power and starts running.

I have downloaded the Arduino IDE version 1.0.5 r2 which I believe is the latest. It lets me choose the target Arduino (eg the Nano) and the "serial port" to talk to it and it can upload code to run on the arduino board. That way I have run a few examples and have also written my own short programs with the Nano on a breadboard and some pots, LEDs, resistors etc.

However the Arduino IDE does not have any debugging features, eg single step, breakpoints, view memory/registers/pins etc.

I have downloaded Atmel Studio 6.2 (which is huge BTW) and also an addon that supposedly will let me debug, it is "ArduinoForAtmelStudio.msi". However when I start the Atmel Studio I cannot see any options to talk or do anything with the connected Nano.

I am not sure what the next steps should be for me to be able to debug my code. Do I need to buy more hardware? Or can it be done with the Nano as is? What software do I need?

many thanks

KeithRB

Debugging on the Arduino is done old school. Judiciously inserted print statements.

BulldogLowell

adding a lot of Serial.print() is one way.  you can 'see' if the program is proceeding as expected or variables are returning as expected.

you can try ways to turn it on/off like this:

Code: [Select]
#define DEBUG

#ifdef DEBUG
#define debug(x)     Serial.print(x)
#define debugln(x)   Serial.println(x)
#else
#define debug(x)     // define empty, so macro does nothing
#define debugln(x)
#endif


and put your statements in like this:

Code: [Select]
debug("SomeText: ");
debugln("inserted here");


comment out 
Code: [Select]
#define DEBUG
to stop the DEBUG printing

Go Up