Strict Standards: Declaration of cache_instructions::retrieveCache() should be compatible with cache::retrieveCache($clean = true) in /home/stefanix/stefanix.net/inc/cache.php on line 289

Warning: Cannot modify header information - headers already sent by (output started at /home/stefanix/stefanix.net/inc/cache.php:289) in /home/stefanix/stefanix.net/inc/auth.php on line 295

Strict Standards: Only variables should be passed by reference in /home/stefanix/stefanix.net/doku.php on line 71

Warning: Cannot modify header information - headers already sent by (output started at /home/stefanix/stefanix.net/inc/cache.php:289) in /home/stefanix/stefanix.net/inc/actions.php on line 154
stefanix :: arduino
ABOUT PROJECTS RESUME
arduino

Arduino is a software and hardware solution for physical computing. At its core it is based on the open-source, cross-platform tool chain avr-gcc. Because of this the Arduino IDE is also super useful for working with AVR chips and custom boards.

arduino_usb.jpg

Pin Mapping

//       ATMEL ATMEGA168
//
//            +-\/-+
//      PC6  1|    |28  PC5  19  5 (analog)
//  0   PD0  2|    |27  PC4  18  4 (analog)
//  1   PD1  3|    |26  PC3  17  3 (analog)
//  2   PD2  4|    |25  PC2  16  2 (analog)
//  3   PD3  5|    |24  PC1  15  1 (analog)
//  4   PD4  6|    |23  PC0  14  0 (analog)
//      VCC  7|    |22  GND
//      GND  8|    |21  AREF
//      PB6  9|    |20  AVCC
//      PB7 10|    |19  PB5  13
//  5   PD5 11|    |18  PB4  12
//  6   PD6 12|    |17  PB3  11
//  7   PD7 13|    |16  PB2  10
//  8   PB0 14|    |15  PB1  9
//            +----+

Arduino and the USBtinyISP

The Arduino IDE (version > 0011) can be set up to use an external programmer. A quick guide is here:

http://www.arduino.cc/en/Hacking/Programmer

Basically the preference.txt file has to be edited and the upload.using variable needs to be set to usbtinyisp or any other kind of programmer from the programmers.txt file.

There is also a handy way for using custom boards. I like using the atmega168 without an external crystal. For this to work you have to add a new entry to boards.txt. E.g:

atmega168_8MHz.name=ATmega168 with internal Clock

atmega168_8MHz.upload.protocol=usbtiny
atmega168_8MHz.upload.maximum_size=14336
atmega168_8MHz.upload.speed=19200

atmega168_8MHz.bootloader.low_fuses=0xff
atmega168_8MHz.bootloader.high_fuses=0xdd
atmega168_8MHz.bootloader.extended_fuses=0x00
atmega168_8MHz.bootloader.path=atmega168
atmega168_8MHz.bootloader.file=ATmegaBOOT_168_ng.hex
atmega168_8MHz.bootloader.unlock_bits=0x3F
atmega168_8MHz.bootloader.lock_bits=0x0F

atmega168_8MHz.build.mcu=atmega168
atmega168_8MHz.build.f_cpu=8000000L
atmega168_8MHz.build.core=arduino

You also need to setup any new atmega168 chip to use the internal clock with 8MHz:

/Applications/arduino-0011/hardware/tools/avr/bin/avrdude -C/Applications/arduino-0011/hardware/tools/avr/etc/avrdude.conf -c usbtiny -p m168 -U lfuse:w:0xe2:m -U hfuse:w:0xdd:m

More on fuse bits here.

Then in the Arduino IDE I can select a the ATmega168 with internal Clock board and the coompile/upload button works just like with a standard bootloader-based arduino board. Timing function will be adapted to the slower clock speed.

Serial Debugging

On OSX screen is preinstalled

screen /dev/tty.yourvirtualserialdevice 9600

To quit the screen app, type control-A, then control-\

Show pagesource Old revisions Backlinks Index Recent changes
arduino.txt · Last modified: 2009/04/26 01:30 (external edit)

Strict Standards: Only variables should be passed by reference in /home/stefanix/stefanix.net/doku.php on line 79