Difference between revisions of "Arduino"

From ArchWiki
Jump to: navigation, search
(Using a Makefile instead of the IDE)
m (Accessing serial)
Line 39: Line 39:
Modify ~/.arduino/preferences.txt
Modify ~/.arduino/preferences.txt
Change serial port from COM1 to your serial port. You can find out what your serial is port with:
Change serial port from COM1 to your serial port. You can find out what your serial port is with:
   ls /dev/ | grep "USB"
   ls /dev/ | grep "USB"

Revision as of 01:47, 18 April 2011

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It's intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments.

If you have a 64 bit Arch this page is an alternative tested method of installing Arduino which works on version 17.

More information is availible on the Arduino HomePage.

Install packages from official repositories

Install the avr-libc, avrdude, binutils-avr and gcc-avr packages from community.

  • avr-libc - standard C library
  • avrdude - very well known programmer
  • binutils-avr - assembler
  • gcc-avr - gcc C compiler support
# pacman -S avr-libc avrdude binutils-avr gcc-avr

Install arduino package from AUR

Download arduino from the AUR and install it.

mkdir arduino_build && cd arduino_build &&
wget http://aur.archlinux.org/packages/arduino/arduino/PKGBUILD &&
makepkg -i

Running arduino for the first time

If the file /usr/share/arduino/lib/targets/libraries/Wire/utility/twi.o does not exist arduino will try and create it. Normal users don't have permission to write there so this will fail. Run arduino as root so it can create the file, after the file has been created it can be run under a normal user.

Other info

Accessing serial

The arduino board communicates with the PC via a serial connection or a serial over USB connection. So the user needs read/write access to the serial device file. Udev creates files in /dev/tts/ owned by group uucp so adding the user to the uucp group gives the required read/write access.

gpasswd -a <user> uucp

Modify ~/.arduino/preferences.txt

Change serial port from COM1 to your serial port. You can find out what your serial port is with:

 ls /dev/ | grep "USB"

This is the line to change in ~/.arduino/preferences.txt:


Working with Uno/Mega2560

The Arduino Uno and Mega2560 have an onboard USB interface (an Atmel 8U2) that accepts serial data, so they are accessed through /dev/ttyACM0 created by the cdc-acm kernel module when it is plugged in.

The 8U2 firmware may need an update to ease serial communications. See [1] for more details and reply #11 for a fix. The original arduino bbs, where you can find an image explaining how to get your Uno into DFU, is now in a read-only state. If you don't have an account to view the image, see [2].

You can perform a general function test of the Uno by putting it in loopback mode and typing characters into the arduino serial monitor at 115200 baud. It should echo the characters back to you. To put it in loopback, short pins 0 -> 1 on the digital side and either hold the reset button or short the GND -> RESET pins while you type.

Using a Makefile instead of the IDE

Update 2011-03-12. Arduino Is not shipping a Makefile with version (22). The Makefile from the dogm128 project works for me though.

Instead of using the arduino IDE it's possible to use another editor and a Makefile.

Set up a directory to program your Arduino and copy the Makefile into this directory. A copy of the Makefile can be obtained from arduino website or from /usr/share/arduino/hardware/cores/arduino/Makefile

You will have to modify this a little bit to reflect your settings. The makefile should be pretty self explainatory. Here are some lines you may have to edit.

PORT = usually /dev/ttyUSBx, where x is the usb serial port your arduino is plugged into
TARGET = your sketch's name
ARDUINO = /usr/share/arduino/lib/targets/arduino

Depending on which library functions you call in your sketch, you may need to compile parts of the library. To do that you need to edit your SRC and CXXSRC to include the required libraries.

Now you should be able to make && make upload to your board to execute your sketch.

Using Scons instead of the IDE

Using scons together with arscons it is very easy to use to compile and upload Arduino projects from the command line. Scons is based on python and you will need python-pyserial to use the serial interface. Install everything with

# pacman -S python-pyserial scons

That will get the dependencies you need too. You will also need Arduino itself so install it as described above. Create project directory (eg. test), then create a arduino project file in your new directory. Use the same name as the directory and add .pde (eg. test.pde). Get the SConstruct script from arscons and put it in your directory. Have a peek in it and, if necessary, edit it. It's a python script. Edit your project as you please, then run

$ scons                # This will build the project
$ scons upload         # This will upload the project to your Arduino