If you've written just two lines or arduino code, you know how annoying it is to use the IDE the SDK comes with. Since we've recently been using arduino quite a lot in the
workshop, I figured I'll prepare my system for a more comfortable (relative) environment.
Arduino IDE Cons
Poor text editing
Slow startup
Slow compilation/verification
Let's solve this. I'm using a debian based system, so if you're not on one. Tough Luck! You'll need to do some research :-(
Grab the dependencies:
sudo apt-get install gcc-avr avr-libc avrdude
Grab the Makefile
Makefile: (This is a newer version than the old one linked in arduino's playground)
-
Create your project directory, create your arduino project file, copy the makefile:
$ mkdir helloworld
$ cd helloworld
$ touch hello.ino
$ cp /path/to/Makefile .
All thats left to do is to modify the Makefile.
Here are the steps I used:
1- Open the Makefile and change the
TARGET to
hello
2- Modify the
ARDUINO_DIR to the point to your arduino installation
3- Modify the
ARDUINO_MODEL based on the model you have.
4- You may or may not need to check the PORT, that really depends on the operating system you're on.
5- Replace all instances of
.pde in the Makefile to
.ino (Processing and Arduino used the same extension before .pde, but now arduino switched to ino, so this accomodates that change)
Now let's add some simple code to test, open your
hello.ino file and add the following:
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println("Does it work?");
delay(1000);
}
Save your code and run the following to compile/verify:
$ make
If all goes well, you are now ready to upload your code:
$ make upload
If all goes well, the MCU is now sending "Does it work?" to your serial port on baud 9600, so let's read that!
$ cat /dev/ttyACM0
Does it work?
Does it work?
Does it work?
Does it work?
Does it work?
Enjoy.