Arduino

From ThorstensHome
Revision as of 15:58, 8 June 2012 by WikiSysop (Talk)

Jump to: navigation, search

I got an Arduino Uno for my birthday. Documentation is poor, here I try to get it working.

Contents

What it is

When I got the Arduino Uno I did not know what it is. Here is how it looks:

Arduino-all-200.png

The documentation just says "Thanks for supporting Arduino", that it is open-source, environmentally friendly and has limited warranty.

SUSE Linux 12.1x64

  • use a computer with SUSE Linux 12.1x64. If you do not have it, use a virtual machine.
  • download the software
  • unpack it
tar xvzf Downloads/arduino-1.0.1-linux64.tgz 
  • call arduino:
cd arduino-1.0.1/
./arduino 
  • select file -> examples -> basics -> blink -> upload
  • you see the LED on the Arduino blinking

FedOrA

trying with avrdude

  • use a computer with FedOrA 16 x32. If you do not have it, use a virtual machine with a 20 GB harddisk
  • connect the arduino to USB
  • open a console
  • enter
yum install uisp avr-binutils avr-gcc avr-libc
yum install avrdude
  • Now I try to erase the device, but it does not work:
avrdude -c stk500v2 -P /dev/ttyACM0 -e -p atmega128
avrdude: stk500_2_ReceiveMessage(): timeout
avrdude: stk500_2_ReceiveMessage(): timeout
maybe the -p atmega128 is wrong

trying with Arduino's software

./arduino
  • select file -> examples -> basics -> blink -> upload
  • get an error "port com1 not found"
  • now as root it worx!

Traffic lights

Reading http://arduino.cc/en/Tutorial/Tone3 I get Arduino is for controlling attached electronics like speakers. So I get this board and make traffic lights.

Batch mode

Now I want my computer to control the traffic lights on my Arduino. So I need a way to upload information to my Arduino without the need for manual interaction. I call this the batch mode. Everything is done programmable over shell commands. The command so far does not work:

# avrdude -c stk500v2 -P /dev/ttyACM0 -e -p atmega128
avrdude: stk500_2_ReceiveMessage(): timeout

We know that the Arduino software is just a wrapper around avrdude, so I start the Arduino software and record its syscalls into a file:

strace ./arduino 2>file

then I look into the file to find out how avrdude has been called:

# cat file | grep avrdude
[pid 10031] stat("/root/arduino-1.0.1/hardware/tools/avrdude", {st_mode=S_IFREG|0755, st_size=960618, ...}) = 0
[pid 10277] execve("/root/arduino-1.0.1/hardware/tools/avrdude", ["/root/arduino-1.0.1/hardware/too"..., "-C/root/arduino-1.0.1/hardware/t"..., "-q", "-q", "-patmega328p", "-carduino", "-P/dev/ttyACM0", "-b115200", "-D", "-Uflash:w:/tmp/build154763532118"...], [/* 102 vars */] <unfinished ...>
[pid 10277] open("/root/arduino-1.0.1/hardware/tools/avrdude.conf", O_RDONLY) = 3
[pid 10277] read(3, "# $Id: avrdude.conf.in 991 2011-"..., 8192) = 8192
[pid 10277] stat("/root/.avrduderc", 0x7fff49f7faf0) = -1 ENOENT (No such file or directory)

Seems it has been call -carduino -patmega328p so I do the same and it works:

# avrdude -carduino -P/dev/ttyACM0 -e -p atmega328p                                                                                                                                                             
                                                                                                                                                                                                                                           
avrdude: AVR device initialized and ready to accept instructions                                                                                                                                                                            
                                                                                                                                                                                                                                             
Reading | ################################################## | 100% 0.00s                                                                                                                                                                   
                                                                                                                                                                                                                                             
avrdude: Device signature =  0x1e950f                                                                                                                                                                                                        
avrdude: erasing chip                                                                                                                                                                                                                       
                                                                                                                                                                                                                                           
avrdude: safemode: Fuses OK                                                                                                                                                                                                                 
                                                                                                                                                                                                                                           
avrdude done.  Thank you.

2012-06-08

with an LED I find out: GND corresponds to - on a battery, 3.3V is +3.3V.

Questions

  • why do the LEDs have legs with a differing length?
  • why does the thing (I guess it is a turnable resistor) not fit into the Arduino board?
  • what is the name of the one board and the other board?
  • why are the ports on the Arduino some labeled with a tilde ~ others not: RX0, TX1, 2, ~3, 4, ~5, ~6, 7, 8, ~9, ~10, ~11, 12, 13?

See also