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. More information is availible on the [http://www.arduino.cc/ Arduino HomePage].

+

[[Category:Mathematics and science]]

−

+

Arduino is an open-source electronics prototyping platform based on flexible, easy-to-use hardware and software. It is intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. More information is available on the [http://www.arduino.cc/ Arduino HomePage].

==Installation==

==Installation==

−

Install {{Package AUR|arduino}} from the [[AUR]].

+

* Install {{AUR|arduino}} from the [[Arch User Repository|AUR]].

−

+

* Add yourself to the {{ic|uucp}} [[Users and Groups|group]]. (More information in the next section: "Accessing serial")

−

Add the following modules to your /etc/rc.conf file.

+

−

cdc-acm

+

−

ftdi_sio

+

−

+

−

Load them manually with modprobe so you don't have to reboot:

+

−

+

−

# modprobe --all cdc-acm ftdi_sio

+

−

+

−

===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.

+

===Arduino Due===

+

You need the version 1.5beta of the arduino ide. You can download an archive with the compiled version at the [http://arduino.cc/en/Main/Software Arduino software download] page.

==Configuration==

==Configuration==

Line 27:

Line 19:

gpasswd -a <user> uucp

gpasswd -a <user> uucp

−

{{Note|You'll have to logout and login again for this to take effect.}}

+

{{Note|You will have to logout and login again for this to take effect.}}

−

Modify ~/.arduino/preferences.txt

+

Briefly run the {{ic|arduino}} command and stop it, then modify {{ic|~/.arduino/preferences.txt}} .

−

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

+

Change serial port from COM1 to your serial port. With your arduino board connected, you can find out what your serial port is with:

−

ls /dev/ | grep "USB"

+

ls /dev/ttyUSB* /dev/ttyACM*

−

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

+

If in doubt, unconnect the board and look which of these disappears, and/or monitor {{ic|/var/log/everything.log}}.

−

serial.port=/dev/ttyUSB0

+

The line to change in {{ic|~/.arduino/preferences.txt}} should look something like this when you are done:

−

===Associate .pde files with the Arduino IDE===

+

serial.port=/dev/ttyACM3

−

edit /usr/bin/arduino so it looks like this:

+

Rerun {{ic|arduino}}. If you get a message like "Arduino Uno on /dev/tty*" message in the GUI's lower right corner, connection has been established.

−

/usr/share/arduino/arduino "$*"

+

== stty ==

−

Then change the last line in /usr/share/arduino/arduino to look like this:

Now you can run "arduino /some/path/sketch.pde and it should open instead of a blank sketch

+

Reading what your Arduino has to tell you

+

cat /dev/ttyACM0

==Working with Uno/Mega2560==

==Working with Uno/Mega2560==

Line 55:

Line 50:

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 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 [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286350399] 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 [http://www.scribd.com/doc/45913857/Arduino-UNO].

+

The 8U2 firmware may need an update to ease serial communications. See [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286350399] 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 do not have an account to view the image, see [http://www.scribd.com/doc/45913857/Arduino-UNO].

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.

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.

Line 64:

Line 59:

Arduino Uno

Arduino Uno

−

Secondly you must ensure you have selected the correct serial port from the Tools->Serial Port menu item:

+

Secondly you must ensure you have selected the correct serial port from the Tools->Serial Port menu item as explained above.

−

/dev/ttyACM0

+

Once these are done you should be able to write and upload sketches to your Arduino Uno without any issues.

Once these are done you should be able to write and upload sketches to your Arduino Uno without any issues.

−

==Alternatives for IDE==

==Alternatives for IDE==

−

If you prefer working from terminal there are some other options to choose from.

+

===ArduIDE===

+

+

ArduIDE is a Qt-based IDE for Arduino. {{aur|arduide-git}} is available in the [[AUR]].

+

+

If you prefer working from terminal, below there are some other options to choose from.

+

+

===gnoduino===

+

+

{{aur|gnoduino}} is an implementation of original Arduino IDE for GNOME available in the [[AUR]]. The original Arduino IDE software is written in Java. This is a Python implementation and it is targeted at GNOME but will work on xfce4 and other WM. Its purpose is to be light, while maintaining compatibility with the original Arduino IDE. The source editor is based on gtksourceview.

===Scons===

===Scons===

Line 80:

Line 81:

# pacman -S python-pyserial scons

# 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 [http://code.google.com/p/arscons/source/browse/trunk/SConstruct 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

+

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 [http://arscons.googlecode.com/git/SConstruct SConstruct] script from arscons and put it in your directory. Have a peek in it and, if necessary, edit it. It is a python script. Edit your project as you please, then run

$ scons # This will build the project

$ scons # This will build the project

Line 88:

Line 89:

Update 2011-03-12. Arduino Is not shipping a Makefile with version (22). The Makefile from the [http://code.google.com/p/dogm128/source/browse/libraries/Dogm/examples/SpaceTrash/Makefile.uno_dogs102 dogm128] project works for me though.

Update 2011-03-12. Arduino Is not shipping a Makefile with version (22). The Makefile from the [http://code.google.com/p/dogm128/source/browse/libraries/Dogm/examples/SpaceTrash/Makefile.uno_dogs102 dogm128] project works for me though.

−

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

+

Instead of using the arduino IDE it is 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 [http://www.arduino.cc/en/uploads/Hacking/Makefile arduino website] or from /usr/share/arduino/hardware/cores/arduino/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 /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.

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.

Ino ([https://github.com/amperka/ino]) is a command line toolkit for working with arduino hardware. {{aur|ino}} is available in the [[AUR]].

==Troubleshooting==

==Troubleshooting==

−

===gcc-avr-4.6.1-1 results to compilation errors===

+

===delay() function does not work===

+

{{Out of date|the current arduino-git package is reported in the talk page as not being affected by this issue.|section=Update troubleshooting?}}

+

There are some cases where the delay() function does not work, causing programs such as the example [http://www.arduino.cc/en/Tutorial/Blink Blink] to malfunction.

+

It appears that the Arch compiler sometimes generates code that writes to addresses before the start of memory. RAM starts at address 0x200 on the mega, but the Blink code has the delay() timer variables located at 0x100-0x10b. This only seems to happen when the code contains no initialized global variables (.data segment in asm-speak) - the linker is told that the data segment starts at 0x200, but if there is nothing to go in it it generates an incorrect start address for the uninitialized global variables (.bss segment). Since the timer variables are uninitialized globals (or globals initialized to zero) they end up at an illegal address.

−

Current gcc-avr-4.6.1-1 results to compilation errors such as

+

There are currently two ways to bypass this issue.

−

In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Tone.cpp:37:0:

+

−

/usr/share/arduino/hardware/arduino/cores/arduino/pins_arduino.h:66:48: error: variable 'port_to_mode_PGM' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

+

−

In order to bypass this problem, downgrade to previous gcc-avr-4.6.0-3.

You can grab it from [http://arm.konnichi.com/community/os/i686/gcc-avr-4.6.0-3-i686.pkg.tar.xz here].

+

−

===64-bit ===

+

{{bc|

+

/*

+

Blink

+

Turns on an LED on for one second, then off for one second, repeatedly.

+

+

This example code is in the public domain.

+

*/

−

When building with pacman, gcc-multilib and binutils-multilib were installed. However testing has revealed that the multilib versions are not required and the Arduino Uno works fine with the regular 64 bit versions of these programs.

+

void setup() {

+

// initialize the digital pin as an output.

+

// Pin 13 has an LED connected on most Arduino boards:

+

pinMode(13, OUTPUT);

+

Serial.begin(9600);

+

}

−

===delay() doesn't work===

+

void loop() {

−

There are some cases where the delay() function doesn't work, causing programs such as the example "Blink" program to malfunction. See http://arduino.cc/forum/index.php/topic,56841.msg410902.html#msg410902 and http://arduino.cc/forum/index.php?topic=59409.0

+

digitalWrite(13, HIGH); // set the LED on

−

Fedora has the same problem with binutils 2.21 https://bugzilla.redhat.com/show_bug.cgi?id=688645

+

delay(1000); // wait for a second

−

Downgraded packages that work are binutils-avr 2.20.1-3 and gcc-avr 4.5.1-2. Unknown whether there is an upstream bug report.

If you are using gcc-avr >= 4.3.5 then there is a C++ bug in the gcc-avr toolchain which builds bad firmware for the Atmel2560 processors. gcc-avr must be rebuilt using a patch found at [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263]. You can read more about the problems at [http://andybrown.me.uk/ws/2010/10/24/the-major-global-constructor-bug-in-avr-gcc/].

You may also find that your Tools > Serial Port menu is greyed out, and you get this error message when attempting to upload a sketch:

+

'''Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools > Serial Port menu?'''

+

+

Either way, this is probably because you don't have write permissions on ''/run/lock directory''. Try this to see if this solves your problem :

+

{{bc|

+

sudo chmod 777 /run/lock

+

}}

+

+

/run/lock is created on boot by /usr/lib/tmpfiles.d/legacy.conf (both on systemd and initscripts). To make the permissions permanent, copy the file /usr/lib/tmpfiles.d/legacy.conf to /etc/tmpfiles.d/ and edit it there. Find the line that sets the permissions of /run/lock and change it to

+

{{bc |

+

d /run/lock 0775 root lock -

+

}}

+

Then add yourself to the lock group using

+

{{bc |

+

gpasswd -a username lock

+

}}

+

and reboot.

+

+

=== Error opening serial port ===

+

You may see the serial port initially when the IDE starts, but the TX/RX leds do nothing when uploading. You may have previously changed the baudrate in the serial monitor to something it does not like. Edit ~/.arduino/preferences.txt so that serial.debug_rate is a different speed, like 115200.

+

+

=== Arduino Mega2560 and new gcc-avr ===

+

+

If you are using gcc-avr >= 4.3.5 then there is a C++ bug in the gcc-avr toolchain which builds bad firmware for the Atmel2560 processors. gcc-avr must be rebuilt using a patch found at [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263]. You can read more about the problems at [http://andybrown.me.uk/ws/2010/10/24/the-major-global-constructor-bug-in-avr-gcc/]. This bug has been fixed in 4.7.0 and backported to 4.5.4 [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45263].

Here is the patch for gcc:

Here is the patch for gcc:

−

<pre>

+

{{bc|

--- gcc-4.5.1.orig/gcc/config/avr/libgcc.S 2009-05-23 17:16:07 +1000

--- gcc-4.5.1.orig/gcc/config/avr/libgcc.S 2009-05-23 17:16:07 +1000

+++ gcc-4.5.1/gcc/config/avr/libgcc.S 2010-08-12 09:38:05 +1000

+++ gcc-4.5.1/gcc/config/avr/libgcc.S 2010-08-12 09:38:05 +1000

Line 162:

Line 241:

cpi r28, lo8(__dtors_end)

cpi r28, lo8(__dtors_end)

cpc r29, r17

cpc r29, r17

−

</pre>

+

}}

The easiest way to rebuild gcc-avr is using ABS and makepkg.

The easiest way to rebuild gcc-avr is using ABS and makepkg.

+

+

=== Arduino Mega2560 and deprecated items in avr-libc ===

+

+

The following error is known to occur when compiling using avr-libc versions newer than 1.8.0 with the Arduino Mega 2560.

This problem is discussed in further detail [http://arduino.cc/forum/index.php/topic,92364.0.html here]. To fix this, you need to enable deprecated avr-libc items in an Arduino header file.

+

+

{{hc|/usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h|

+

#ifndef Arduino_h

+

#define Arduino_h

+

+

// start: fix the compatibility issue

+

#define __AVR_LIBC_DEPRECATED_ENABLE__ 1

+

// end: fix the compatibility issue

+

+

#include <stdlib.h>

+

...

+

}}

+

+

=== Missing twi.o ===

+

+

If the file /usr/share/arduino/lib/targets/libraries/Wire/utility/twi.o does not exist arduino may try to create it. Normal users do not 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 arduino can be run under a normal user.

+

+

=== Unable to upload sketch to your Arduino ===

+

+

Install the [https://aur.archlinux.org/packages.php?ID=8389 rxtx] package from the AUR. That package is the working Java library for Serial IO.

+

+

=== Consistent naming of arduino devices ===

+

+

If you have more than one arduino you may have noticed that they names /dev/ttyUSB[0-9] are assigned in the order of connection. In the IDE this is not so much of a problem, but when you have programmed your own software to communicate with an arduino project in the background this can be annoying. Use the following udev rules to assign static symlinks to your arduino's:

Revision as of 16:17, 13 May 2013

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

Installation

Add yourself to the uucpgroup. (More information in the next section: "Accessing serial")

Arduino Due

You need the version 1.5beta of the arduino ide. You can download an archive with the compiled version at the Arduino software download page.

Configuration

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

Note: You will have to logout and login again for this to take effect.

Briefly run the arduino command and stop it, then modify ~/.arduino/preferences.txt .

Change serial port from COM1 to your serial port. With your arduino board connected, you can find out what your serial port is with:

ls /dev/ttyUSB* /dev/ttyACM*

If in doubt, unconnect the board and look which of these disappears, and/or monitor /var/log/everything.log.

The line to change in ~/.arduino/preferences.txt should look something like this when you are done:

serial.port=/dev/ttyACM3

Rerun arduino. If you get a message like "Arduino Uno on /dev/tty*" message in the GUI's lower right corner, connection has been established.

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 do not 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.

Running Arduino Uno

Once Arduino is running you must ensure you have selected the correct board from the Tools->Boards menu item:

Arduino Uno

Secondly you must ensure you have selected the correct serial port from the Tools->Serial Port menu item as explained above.

Once these are done you should be able to write and upload sketches to your Arduino Uno without any issues.

Alternatives for IDE

ArduIDE

ArduIDE is a Qt-based IDE for Arduino. arduide-gitAUR is available in the AUR.

If you prefer working from terminal, below there are some other options to choose from.

gnoduino

gnoduinoAUR is an implementation of original Arduino IDE for GNOME available in the AUR. The original Arduino IDE software is written in Java. This is a Python implementation and it is targeted at GNOME but will work on xfce4 and other WM. Its purpose is to be light, while maintaining compatibility with the original Arduino IDE. The source editor is based on gtksourceview.

Scons

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 is 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

Makefile

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 is 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 /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.

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.

Arduino-CMake

Using arduino-cmake and CMake you can build Arduino firmware from the command line using multiple build systems. CMake lets you generate the build system that fits your needs, using the tools you like. It can generate any type of build system, from simple Makefiles, to complete projects for Eclipse, Visual Studio, XCode, etc.

delay() function does not work

There are some cases where the delay() function does not work, causing programs such as the example Blink to malfunction.
It appears that the Arch compiler sometimes generates code that writes to addresses before the start of memory. RAM starts at address 0x200 on the mega, but the Blink code has the delay() timer variables located at 0x100-0x10b. This only seems to happen when the code contains no initialized global variables (.data segment in asm-speak) - the linker is told that the data segment starts at 0x200, but if there is nothing to go in it it generates an incorrect start address for the uninitialized global variables (.bss segment). Since the timer variables are uninitialized globals (or globals initialized to zero) they end up at an illegal address.

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
Serial.begin(9600);
}
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
}

char dummyvariablecuzmaintainerborkedthecompiler = 123; // force something into the .data segment with non-zero initializer
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
void setup() {
dummyvariablecuzmaintainerborkedthecompiler++; // stops the linker from removing the global variable
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
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
}

Fedora has the same problem with binutils 2.21 (bug report).
Downgraded packages that work are binutils-avr 2.20.1-3 and gcc-avr 4.5.1-2.
There is also an upstream bug report here but no one has replied yet.

Error when launching Arduino IDE or uploading sketch

If you run the Arduino IDE as a normal user (you should do that of course), you may get this error message :
check_group_uucp(): error testing lock file creation Error details:Permission denied

You may also find that your Tools > Serial Port menu is greyed out, and you get this error message when attempting to upload a sketch:
Serial port '/dev/ttyACM0' not found. Did you select the right one from the Tools > Serial Port menu?

Either way, this is probably because you don't have write permissions on /run/lock directory. Try this to see if this solves your problem :

sudo chmod 777 /run/lock

/run/lock is created on boot by /usr/lib/tmpfiles.d/legacy.conf (both on systemd and initscripts). To make the permissions permanent, copy the file /usr/lib/tmpfiles.d/legacy.conf to /etc/tmpfiles.d/ and edit it there. Find the line that sets the permissions of /run/lock and change it to

d /run/lock 0775 root lock -

Then add yourself to the lock group using

gpasswd -a username lock

and reboot.

Error opening serial port

You may see the serial port initially when the IDE starts, but the TX/RX leds do nothing when uploading. You may have previously changed the baudrate in the serial monitor to something it does not like. Edit ~/.arduino/preferences.txt so that serial.debug_rate is a different speed, like 115200.

Arduino Mega2560 and new gcc-avr

If you are using gcc-avr >= 4.3.5 then there is a C++ bug in the gcc-avr toolchain which builds bad firmware for the Atmel2560 processors. gcc-avr must be rebuilt using a patch found at [4]. You can read more about the problems at [5]. This bug has been fixed in 4.7.0 and backported to 4.5.4 [6].

Missing twi.o

If the file /usr/share/arduino/lib/targets/libraries/Wire/utility/twi.o does not exist arduino may try to create it. Normal users do not 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 arduino can be run under a normal user.

Unable to upload sketch to your Arduino

Install the rxtx package from the AUR. That package is the working Java library for Serial IO.

Consistent naming of arduino devices

If you have more than one arduino you may have noticed that they names /dev/ttyUSB[0-9] are assigned in the order of connection. In the IDE this is not so much of a problem, but when you have programmed your own software to communicate with an arduino project in the background this can be annoying. Use the following udev rules to assign static symlinks to your arduino's: