You would like to program with Arduino but you can't do this with the Arduino Software provided.
Instead you would prefer to use your favorite IDE: Eclipse.
That's what we're going to see in this Eclipse and Arduino setup tutorial from scratch.
We are going to see settings for the Arduino ADK ATmega 2560 and the Arduino Uno.
Linux Ubuntu 12.04
The avr-gcc compiler
Openjdk, the open source version of the JDK (Java Development Kit)
Eclipse Juno CDT (or JavaEE)
Arduino library
We need the JDK and we will use the open source version. I invite you to install the version 6 (and not the 7) due to security issues in the seventh one.
This version is the OpenJDK 6 and you can either install it with the USC (Ubuntu Software Center) or with the following command line:
sudo apt-get install openjdk-6-jdk
The compiler is avr-gcc.
To dowload it, two solutions:
Either go in the USC and search for: gcc-avr
Or type the following command line:
sudo apt-get install avrdude binutils-avr gcc-avr avr-libc gdb-avr
Once downloaded, the compiler is available by typing in your shell:
avr-gcc
You can note the difference between the gcc-avr and avr-gcc writings. A bit confused at beginning.
Download Eclipse Juno CDT ou Java EE on the official website: http://www.eclipse.org/
Open Eclipse
Click on Help > Install New Software
On the text input on the right of "Work with :" there is a little triangle (at the left of the Add... button). Click it and select: Juno - http://download.eclipse.org/releases/juno
Wait for the list
Once the list is there, click on Programming Languages to display its content
Select:
Click Next > Next
Accept agreement
Click Finish
Plugins are installing themselves and then Eclipse asks to restart, click Yes
Once restarted, click Help > Eclipse MarketPlace
In the text input Find, write avr then click Go on the right
Once the AVR Eclipse Plugin is found, click Install and Eclipse should restart
Create a new C++ project, select AVR Cross Target Application then Empty Project (the toolchain AVR-GCC Toolchain is already selected by default) and write the following project name:
proj-1 then click Next twice
Right click on proj-1 > Properties > ADR > Target Hardware, fill Type by ATmega2560 (or ATmega328p for the Uno) and Frequency by 16000000, click Finish.
Right click on the project > Properties > AVR > AVRDude
In the Programmer tab, click New on the right
The window Edit ADRDude Programmer Configuration New Configuration opens
In Configuration Name, write Arduino ADK ATmega 2560 for example (or Arduino Uno)
In Programmer Hardware (-c), select: Atmel STK500 Version 2.x firmware for the ATmega 2560 (or Atmel STK500 Version 1.x firmware for the Uno) if it was not already done
In Override default port (-P), write: /dev/ttyACM0
In Override default baudrate (-b) select: 115200
Click OK > OK
We have now to download the Arduino library in order to add it to our project.
Go on the following link and select the version of your choice, in my case Linux 64-bit (if you hesitated, you should take the 32-bit version) : http://arduino.cc/en/Main/Software
Once downloaded, extract it where you want, I put it in:
/home/mi-k/soft/arduino
Then take the pins_arduino.h file of our board Mega ADK from:
/home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/variants/mega
(Or /home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/variants/standard for the Uno)
And put it in:
/home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/cores/arduino
So the file pins_arduino.h is now in cores/arduino.
Now in Eclipse > Right click the project > Properties > C/C++ Build > Settings > Tool Settings > AVR Compiler > Directories
Click the tiny plus green icon to add the path until your Arduino library
Select File System and browse until the library folder, for example:
/home/mi-k/soft/arduino/arduino-1.0.3/hardware/arduino/cores/arduino
Click OK > OK
The library is now in the includes of your project
Create a C++ file on your project, for example go.cpp
Within copy paste the following snippet:
#include "Arduino.h" void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); // set the LED on delay(1000); // wait for a second digitalWrite(13, LOW); // set the LED off delay(1000); // wait for a second }
Plug your card on your computer via the USB slot and put a LED on the pin 13.
Build your project and send it to your Arduino Mega ADK (or Uno) board with the AVR icon.
You could also send it by the following command line, by puttin the shell at the root of your project.
For example, you should have this in the directory /home/mi-k/dev/proj-1/:
So, just send your .hex in your board from the directory proj-1/ by typing the following line (with a sudo if access is denied for example to open ttyACM0).
avrdude -p m2560 -c stk500v2 -P /dev/ttyACM0 -b 115200 -F -U flash:w:./Release/proj-1.hex -D
avrdude -p m328p -c stk500v1 -P /dev/ttyACM0 -b 115200 -F -U flash:w:./Release/proj-1.hex -D
Wow, it wasn't so easy.
But you are now free to use your favorite IDE to develop your next Arduino programs.
Congratulations, you made it!
Add new comment