Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:arduino:resources [2015/05/23 19:59] alfred [Links] |
wiki2:arduino:resources [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 4: | Línea 4: | ||
| ==== ... With Eclipse ==== | ==== ... With Eclipse ==== | ||
| + | To program an Arduino with Eclipse you just need to follow the [[http://playground.arduino.cc/Code/Eclipse|Arduino manual for C\C++]]. As it says, you need to: | ||
| + | - Install the [[http://avr-eclipse.sourceforge.net/wiki/index.php/Plugin_Download|AVR plugin]]. Which is just to add the repository: http://avr-eclipse.sourceforge.net/updatesite and install its software. | ||
| + | - Create a C\C++ project type ''AVR Cross Project Application''. | ||
| + | - 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... | ||
| + | * AvrDude: | ||
| + | * Programmer: Atmel STK500 Version 1.x firmware. | ||
| + | * Override default port: /dev/ttyUSB0 | ||
| + | * Override default baurate: 57600 | ||
| + | * In advance tab: Disable device signature check. | ||
| + | * Target Hardware: | ||
| + | * MCU Type: ATmega328P (which can easily be loaded from the MCU). | ||
| + | * MCU clock frequency: 16000000 | ||
| + | |||
| + | === Using a template === | ||
| + | You just need to download [[https://github.com/ricovangenugten/Arduino-Blink-Eclipse-Project|the template]] and extract and import its two projects in your Eclipse workspace. Now you can use the arduino library. | ||
| + | |||
| + | * {{:wiki2:arduino:arduino-blink-eclipse-project-master.zip|Arduino template for Eclipse}} | ||
| + | |||
| + | === Examples === | ||
| + | Blink: | ||
| + | <code c> | ||
| + | #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); | ||
| + | } | ||
| + | } | ||
| + | </code> | ||
| + | Heartbeat: | ||
| + | <code c> | ||
| + | #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); | ||
| + | } | ||
| + | } | ||
| + | </code> | ||
| ===== Links ===== | ===== Links ===== | ||