# Creating a sketch (.HEX) file from a .PDE file

I have been using the Ardunio IDE to edit code for an Arduino sketch.

I was having trouble uploading to the board, so I bought a pocket progammer in response to this question: What possible ways can I upload sketches to arduino mega chips?

Now, using this programmer I can upload .hex files via the command line.

Now I want to create a .HEX file from my existing .PDE files.

The problem is:

• The graphical IDE has a "Upload Sketch" button (which compiles and attempts to upload in one go), but there doesn't seem to be a "Create Sketch" button.
• avr-gcc can create a sketch (I believe) but doesn't recognise .PDE files.

How can I go about creating this Sketch?

When the Arduino IDE compiles your sketch it creates a .HEX file in a temp directory, which is then uses to upload to your board.

The .HEX file will have the same name as your sketch (without the .pde extension), followed by .cpp.hex

I just tried a build and the .HEX file was created in a directory called build2849146248544311107.tmp inside my Temp directory (C:\Users\USERNAME\AppData\Local\Temp\ on Windows 7). Presumably the numbers in the build2849146248544311107.tmp directory name will chanage.

• AHA, found it. I suppose if I need a repeatable build process I'll have to generate MakeFiles, but getting it from the temp directory will suffice for one-offs. – Andrew Shepherd Jul 5 '11 at 1:04

At a project i'm working on we use the basic Makefile delivered by arduino and made some tweaks in it. You would need https://github.com/zarya/OpenCTRL/blob/master/src/c/Arduino.mk and https://github.com/zarya/OpenCTRL/blob/master/src/c/Makefile.sample rename the Makefile.sample to Makefile and you want to change the settings there. You might also want to remove the # at line 272 and place a one at the start of line 273 of Arduino.mk we use this make file on Debian and Ubuntu, hope it's also compatible with other distributions / windows?

The only downside, currently we can only include one external library in our projects. I'll probably fix this problem in the feature although we actually don't need more then one library at the moment :)

• For windows you'll need GNU Make, along with any binaries the Makefile calls. You may well need to edit the Makefile to change lots of paths to said binaries as they probably aren't in Windows' \$PATH environment variable. – Majenko Jul 4 '11 at 8:41

Press Shift and press Upload button in the IDE simultaneously.

By pressing Shift key when clicking on upload button when compiling, a hex file is made in temp folder somewhere in C: drive by name xx.hex where xx is file name.