Tabla de Contenidos

Resources for Arduino

Develop in C\C++

... With Eclipse

To program an Arduino with Eclipse you just need to follow the Arduino manual for C\C++. As it says, you need to:

  1. Install the AVR plugin. Which is just to add the repository: http://avr-eclipse.sourceforge.net/updatesite and install its software.
  2. Create a C\C++ project type AVR Cross Project Application.
  3. Code, build the project, activate the Release build configuration (which is the one that generates the .hex file), and upload to the Arduino (using the Upload project to target device AVR option).

Probably you will have some troubles when upload it. You should configure your the AVRDUDE tool for your device. For a Duemilanove in Linux a configuration (chosen project properties) that works is…

Using a template

You just need to download the template and extract and import its two projects in your Eclipse workspace. Now you can use the arduino library.

Examples

Blink:

#include <avr/io.h>
#include <util/delay.h>
 
int main (void) {
	long i;
	DDRB = 1 << 5;
	while (1) {
		PORTB = 1 << 5;
		_delay_ms(1000);
		PORTB = 0 << 5;
		_delay_ms(1000);
	}
}

Heartbeat:

#include <avr/io.h>
#include <util/delay.h>
 
int main (void) {
	DDRB = 1 << 5;
	while (1) {
		PORTB = 1 << 5; _delay_ms(250);
		PORTB = 0 << 5; _delay_ms(250);
		PORTB = 1 << 5; _delay_ms(250);
		PORTB = 0 << 5; _delay_ms(1000);
	}
}

Notes

Concepts