Difference between revisions of "Arduino with linux"
m (→Building software for Arduino under linux) |
m (→Sample code) |
||
Line 28: | Line 28: | ||
==Sample code== | ==Sample code== | ||
− | + | *[http://javiervalcarce.es/wiki/Program_Arduino_with_AVR-GCC Program Arduino with AVR-GCC] | |
− | |||
[[Category:Hardware]] | [[Category:Hardware]] |
Revision as of 08:08, 22 September 2008
Arduino is a small computer that connects to the pc with usb. Under debian with a 2.6.18-6-686 kernel it is detected automatically by the usbcore driver. Make sure the link on the Arduino is set to usb power and plug it into the powered on pc. The green LED on the Arduino should light.
Type
dmesg
and you should see some messages like this at the end of the output.
usb 1-2: new full speed USB device using uhci_hcd and address 4 usb 1-2: configuration #1 chosen from 1 choice ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected drivers/usb/serial/ftdi_sio.c: Detected FT232BM usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0
This means the Arduino has been detected. There will now be a device in /dev called ttyUSB0 or similar.
ls /dev/ttyUSB*
This is a normal character device and you can send text to it or read from it very simply.
echo foo > /dev/ttyUSB0
The text foo is written to the Arduino over the serial usb line. You should see the small orange LED flicker as the data is recieved by the Arduino. Of course data can be sent in both directions. If you want to read from the Arduino you can do:
tail -f /dev/ttyUSB0
In order for anything to happen, the Arduino must have some kind of program that sends output, otherwise you will see no result.
Building software for Arduino under linux
The Arduino project provides an integrated IDE enviroment to work with your Arduino. This is great if you've never programmed before and are running Windows, Mac OS or Ubuntu desktop enviroments.
Some people prefer to do the programming with a text editor and use make to compile their code. There are a number of free programs that help you to do this. The Arduino uses the Amtel AVR ATMEGA series of microcontrollers.
apt-cache search avr
Gives you a list of some packages that can help you cross compile AVR binaries and flash them (avrdude) onto the Arduino.