IDE & Debugging

Is there any way to create a program with a different IDE? The IDE that comes with Arduino doesn't work well. The tabs never line up, and when I'm typing it likes to randomly delete my code. There are certain key strokes that make no sense to me and I can't figure out how to disable them.

Also, I am wondering if there is a way to debug my program? I have a large program that isn't working and I can't find any way to step through the code line-by-line to see where the error is.

I don't even know for sure what language Arduino is using. If I used another IDE like Visual Studio, I have no idea how I would upload my code, or change board types, because those are built into the Arduino IDE. I don't know how to compile it for ARduino because the Arduino libraries aren't in Visual Studio.

The thing that bothers me the most is the tabs are way off. A tab on one line doesn't always line up with a tab on another line, which means I have to use spaces to format my code to make it readable. It's very frustrating.

Arduino is a version of C++. I am using and online IDE called codebender that is growing on me.

The thing that bothers me the most is the tabs are way off. A tab on one line doesn't always line up with a tab on another line, which means I have to use spaces to format my code to make it readable. It's very frustrating.

I don't seem to have that problem and, in any case, I use Auto Format (Ctrl/T) frequently in the IDE.

The IDE also has the option to use an external editor of your choice but to still compile using the IDE.

I have seen the option for external editor, but I have no idea how it's supposed to work. It's just a check box.

Google, Visual Micro, which is a plug in for Visual Studio and Atmel Studio, which seamlessly integrates the Arduino compiler.

Atmel Studio is based on Visual Studio and can be downloaded and used without restrictions, for free.

The Visual Micro plug-in can be downloaded for free and provides proper syntax highlighting, code completion and tab characters in the source. If you are willing to pay a small license fee, which is well worth it just to support Tim, the Visual Micro developer's sterling work, some additional debugging features are unlocked.

Seriously, Visual Micro, provides Arduino with a professional grade IDE for nothing. Shame it's Windows only.

There is also a plug-in for Eclipse, which is OK but nothing like so well developed. And there is an add on for XCode, which works but just doesn't seem quite so capable or well supported.

I have seen the option for external editor, but I have no idea how it’s supposed to work.

Checking the “use external editor” box causes two (noticable) things to happen:

  1. The Arduino IDE box containing your sketch becomes read only; you can’t make changes in it.
  2. Every action that compiles your sketch (“verify”, “upload”, etc) re-reads the version on disk, instead of using the version in the window.

This simple combination works pretty nicely, IMO.

adele: Is there any way to create a program with a different IDE? The IDE that comes with Arduino doesn't work well. The tabs never line up, and when I'm typing it likes to randomly delete my code. There are certain key strokes that make no sense to me and I can't figure out how to disable them.

Also, I am wondering if there is a way to debug my program? I have a large program that isn't working and I can't find any way to step through the code line-by-line to see where the error is.

I don't even know for sure what language Arduino is using. If I used another IDE like Visual Studio, I have no idea how I would upload my code, or change board types, because those are built into the Arduino IDE. I don't know how to compile it for ARduino because the Arduino libraries aren't in Visual Studio.

The thing that bothers me the most is the tabs are way off. A tab on one line doesn't always line up with a tab on another line, which means I have to use spaces to format my code to make it readable. It's very frustrating.

For all practical purposes the Arduino IDE does not have a build in debugger. You will be told by some that you do not need debugger and Arduino processor cannot support one anyway.( Bunch of BS, but you will get used to ignore such remarks.) The crude solution is to insert Serial and / or modified print ( printf) at breakpoints to output the variables of interest. On Uno you will run out of RAM soon doing that but it can be hacked using PROGMEM and "F" macro. All, printf, F macro and using PROGMEM( on Uno) are on Arduino site documentation.

Due is more useful in debugging using these methods.

Somewhat better solution is to use ATmel Studio, it suppose to have native ARM ( Due) debugger but I have nor found how to use it. There is , for small fee, 3rd party debugger available for ATmel Studio also.

Since most of the "features" of Arduino IDE menus are not documented you just have to try it yourself to find out what they do. For example clicking on { } brackets to show code blocks.

Cheers Vaclav

I am anxiously awaiting "Arduino Zero" (which has extra on-board debugging support) to see if the IDE people have come up with any brilliant simplification of "debugging." (As Vaclav's "I have not found how to use it" implies, traditional debuggers can be complicated, difficult to use, and relatively expensive. The "additional hardware" needed to debug an AVR (which is proprietary) usually costs at least $50. (For ARMs, it's less proprietary, and sometimes more expensive. But more often is included really cheaply on vendor development boards (occupying the same logical spot at the 16u4 on an Uno.)))

Debuggers are nice, but, realistically, they are far from essential. I've been doing embedded programming since the '70s, when we NEVER had debuggers. I've never had a problem I couldn't solve using print statements and other very basic tools. My current project is using a Due to run a machine controlled by four DC servos, a pneumatic cylinder, and about a dozen sensors. The servos are all run by PIDs running on the Due, with quadrature encoder feedback. The code consists of about a dozen inter-connected state machines, and the user interface is via Serial, telnet, or a built-in web server. 150+K of object code, developed over the last 4 months, all debugged using nothing but print, and common sense, and it all works nearly perfectly.

Fancy debuggers make the job a little easier, and a little faster, but you can still get the job done just fine without them, and it will probably make you a better programmer in the process.

Regards, Ray L.

(For some reason, the whole "printf vs "real debugger"" debate has shown up recently on about half-a-dozen different forums that I read. Multiple times, on some of them. Maybe it's the latest in troll food.)

So basically, when I use the "external editor" I just open the files in Notepad++ or Visual Studio to edit the code. Then I have the Arduino editor opened as well, and when I want to compile or upload, I just use the Arduino editor. As long as I've saved the project in the external editor, the changes will compile.

I can use the serial monitor to do the debugging. So I need to delete all of those serial statements before I upload the final project to Arduino? Does it hurt the leave them in the code?

I am using the Mega and I have probably 2,000 lines of code and I'm barely using any of the available memory according to the editor. When I compile it says I've only used a few percent of what is available.

One other thing, what is the ino format for? Visual Studio doesn't understand that format. So I can't write my programs using cpp? Will that have any effect on the Arduino editor when I compile or cause any problems on the micro controller?

westfw: (For some reason, the whole "printf vs "real debugger"" debate has shown up recently on about half-a-dozen different forums that I read. Multiple times, on some of them. Maybe it's the latest in troll food.)

LOL. I think, sometime between 1989 and 2015, someone must have re-invented the word, 'troll.' I always thought posing the question, "Maybe it's troll food?" Could be considered troll like behaviour, similar to Godwin's law. The uncomfortable topic of the question, discourages natural discussion, thus the 'troll' suppresses counter point and imposes their own view.

The debate is essentially, the convenience of a debugger Vs the time it takes, to learn the fundamentally good practices, which obviate the need for a debugger in the first place.

This is a matter of opinion, with no correct answer. Hence the debate can resurface quite naturally, with no ulterior motive, hidden agenda or malicious intention, being involved. The debate itself can be a learning experience. Causing participants to consider or re-consider, different points of view to their own.

I would add to the debate. The few times I have used the Visual Micro debugging features, I ended up spending more time fiddling with the debugger, than isolating faults.

.ino is just the name so that arduino can associate itself with the sketches. If you get the right plugin for VS, it will probably understand the file type. .ino files ARE C++, with some additional preprocessing (concatenating all .ino files in a directory, automatically adding prototypes), and automatic derivation of library paths.

adele: One other thing, what is the ino format for? Visual Studio doesn't understand that format. So I can't write my programs using cpp? Will that have any effect on the Arduino editor when I compile or cause any problems on the micro controller?

Sorry about this http://lmgtfy.com/?q=visual+micro

If you are already using Visual Studio, you really should go take a look at Visual Micro. Once installed, the Arduino tool chain is completely integrated. You can open and create .ino projects. You can compile by clicking a tool-bar button. A serial monitor is built in. This functionality, is all fee to use.

There is a small license fee for the VM serial debugger functionality, which you may pay, if you feel you need a serial debugger. All the other goodness continues to work without it. I paid the license fee because I feel the free functionality is so good, the developer deserves feeding.

adele: So basically, when I use the "external editor" I just open the files in Notepad++ or Visual Studio to edit the code. Then I have the Arduino editor opened as well, and when I want to compile or upload, I just use the Arduino editor. As long as I've saved the project in the external editor, the changes will compile.

I added Arduino specific keywords to NPP as detailed here. I also added a NPP shortcut key that launches the arduino IDE with the active NPP file using the $(FULL_CURRENT_PATH) keyword.

Vaclav: Somewhat better solution is to use ATmel Studio, it suppose to have native ARM ( Due) debugger but I have nor found how to use it.

The better solution, which you have never used?

How do you know it is better, huh?

In the past on custom designs, for debugging I've used LEDs (homebrew Z80, 6809), ICE (8080, 6809), logic analyser with processor personality module (6800, 6809), built-in debugger (transputer, Intel from 286 to Xeon) and JTAG (PowerPC). Now I work on Arm/Linux, and I mostly use printk.

For Arduino, if I can't fix it with a serial print, it's usually fixed with a scope or a couple of channels of cheap USB logic analyser, but both my scope and my analyser have unhealthy amounts of dust on them.

I'm not able to get the Visual Micro program working, but I can just use Visual Studio as an external editor, that seems to work well for me now that I know how it works.

Thanks.

I got this video that might help someone else:

http://youtu.be/LShvIek4cws