Arduino IDE project used library
There is a segment at http://arduino.cc/playground/Code/Eclipse about how to use the arduino IDE project library. I am basically rewriting it like I did it.
Step 1: Verify that you have downloaded the Arduino-0023
In the Last tutorial we had bade sure that our downloaded core and files were in place and that eclipse IDE was configured and ready. I saved it at G:\arduino-0023 and will refer to that. This is the preferred method.
Run the Arduino IDE and select File > Example > Basic > Blink as shown below.
This will bring up a window with a sample project ready. press the play button and it will compile. Now we find the core.a file. In windows explorer, navigate to C:\Users\Inderpreets\Appdata\Local\Temp where you replace Inderpreets with your windows username and search for core.a Copy this file to your Desktop and we will come back to it in a few minutes.
Step 2: New Project in Eclipse
Start Eclipse and select File > New > C++ Project Fill in the blanks as
In the next page, Deselect Debug and Press next. For arduino UNO select atmega328p as the processor and frequency of 16000000Hz.( 16 000 000 no spaces) Click Finish.
Now right click the Blinky01 project and select new source file. I usually use main.cpp as the file name. A new source file will pop up with a few lines of comment. Now for your program.
First we include the WProgram.h file because that adds all necessary headers automatically. Copy the code below.
* Created on: Jan 31, 2012
* Author: Inderpreets
// This method is used for init of vars and stuff- run once
//This run over and over again
digitalWrite(13, HIGH); // set the LED on
delay(500); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(100); // wait for a second
// init must be called
} //end for
}// end main
Step 3: Project Properties
At this point the IDE will point out that a lot of file and references are missing… So we help it find them. Go to your desktop and copy the core.a file. In eclipse right click the blinky01 project and select paste.
Next, right click the blinky01 project and select properties.
Go to C/C++ build > settings as shown
Go to AVR Compiler > Directories and click the add button. A pop up will ask for the directory paste this: “G:\arduino-0023\hardware\arduino\cores\arduino” with the quotes but replace path where applicable. Do the same with AVR C++ Compiler> Directories.
Now Select AVR C++ Linker and select Objects.
Add the object from the workspace as shown above.
At this point you can pretty much click ok ok and build and will be ok. However there are a few extras you should do for other projects like compiler flag settings etc which I will discuss in a different article…
Right now the build should be ok by rightclicking the project and build project and should be error free… How to upload the code to the UNO is a simple matter and is again covered in a separate article.