Programming An ATtiny Using An Arduino

attiny

[Scott] is a big fan of the Arduino platform, and he’s not afraid to admit it. It does all the things he needs, but now and again he would like to use something a bit smaller, without all the bells and whistles the Arduino has to offer. He contemplated using an ATtiny for smaller projects, but after looking into what he would need to program the chip under Linux, he could never find the motivation to give it a go.

That all changed when he discovered the Arduino-Tiny project, which aims to bring a limited Arduino IDE to the ATtiny line of microcontrollers. He found the project to be quite useful, so he put together a brief tutorial that walks through everything you need to get started.

The tutorial is fairly straightforward, and even demonstrates how the Arduino can be used as an ISP for the ATtiny, removing the need to purchase a standalone programmer. Be sure to check it out if you are searching for an easy way to get started with ATtiny chips under Linux.

24 thoughts on “Programming An ATtiny Using An Arduino

  1. Nice, a genuine move to enhance the usability of the ATiny chip for the less experienced hacker, reducing the skills required may result in slower execution should be seen as a step in the right direction.

  2. Interesting. I want to use a little microcontroller but I don’t work in the electronics field and I have not time to learn another platform/language, so I think that this could be very usefull for me and for people like me.
    Surely this is not the best solution in terms of performance but is nice to have the possibility to use this stuff.

  3. I’ve been using this technique for the past month, works really well.

    Don’t forget if your arduino has auto reset to stick a 120ohm resistor on the reset line

  4. I’m baffled – [Scott] claims that programming an ATtiny the normal way would “require either expensive compilers or hard to use C or Assembler” – how are AVR-gcc and avrdude expensive? And how is coding in C any different than coding in the Arduino’s Wiring language (which is C++)?

    Maybe the right solution here is for someone to extend the Arduino IDE to compile and flash straight C[++] to any AVR via avrdude-supported hardware..?

    For all the good the Arduino has done I’m pretty convinced it’s created a fair amount of harm by fostering ignorance :-(

  5. What?
    “Hard to use C or Assembler”? Arduino is a bunch of macros (and libraries) for C anyhow.
    Expensive? AVR-GCC is right in the repositories!
    The only gripe I have with AVR development on Linux is that I could never get AVR Studio’s simulator to work under WINE.

    Who hasn’t programmed their Arduino in assembler?

  6. It’s great giving access to different chips with avr-tiny but does anyone else think the time seems to be somewhat wasted when there seem to be 5 or 6 projects all servicing the same chips? avr-developer.com seems to support the most in case anyone cares, the MIT stuff I know works too.

  7. @aggaz – great comment.

    I’m exactly the same – arduino lowered the entry barriers enough for me to get into the microcontroller world. Extending the environment, and more importantly the language to other devices is awesome.

  8. I’m all for an Arduino as a prototyping platform for throwing quick and dirty ideas together, but when it comes down to implementing these ideas I think they should be thought out and executed in a fashion that isn’t laden with macro’s and dummy functions. The point of a small uC is simplicity and space constraints, why not take that mentality to the code itself?

  9. @trialex
    As Kuy said, “For all the good the Arduino has done I’m pretty convinced it’s created a fair amount of harm by fostering ignorance :-(”

    The ‘language’ is C/C++, Arduino merely has some useful libraries. All a language is, is syntax. If you can write Arduino sketches you can write C! You should have a bash, I don’t reckon you’ll find it as hard as you think and you will definitely learn a valuable skill on the way :)

  10. @kernelcode – I agree that learning the “full” c language would mean I would be a better coder, and be able to do more, but the arduino syntax just makes it so much easier! Compare the code to change a digital pin – I’d rather type Serial.print(); than the equivalent C code everytime – and at 9600bps who cares if it takes and extra clock cycle or two?

    I totally DISAGREE that it is “ignorance” on my part. The arduino syntax allows me to do what I want with my projects, I’m not ignorant that there is more out there that I could do. Similarly I know basic geometry, but I don’t need to understand fourier transforms for what I do day to day. I know it’s out there though, I could look it up, learn about it and use it if I needed to.

  11. @trial
    there is ignorance on you part. Most people can buils some kind of moving cart on wheels with motor, you can call it a car and it will work but we have to ignore efficiency and possability ithat t will blow up. Same here, the fact that it work for you doe not remove ignorance on subject

  12. I’m all for people doing what they want, and if they want to use arduino, fine. But seriously on ubuntu, it took me about all of 5 minutes to get Eclipse w/ AVR plugin and avr-gcc and avr-libc installed using Ubuntu Software Center. It’s actually faster and easier than on windows. avrdude is much clunkier than the nice programmer utility built into avr studio though.

    And how do you ISP an attiny if you disable the reset line?

  13. @grid – You can’t without a high-voltage programmer :(

    @trialex – I can see that, I guess we have different mentalities. For me, it appealed more to write my own USART library – good fun, educational, and can be built to exacting specifications. In any project where you would want to use ‘Serial.print()’ I use

    #include “../usart/usart.h”


    usart_send(“Hello!”, 6)

  14. @therian
    I think you are basically right, there is ignorance, but your example is just too extreme.
    Please consider that we are not working with something dangerous that can blow up and that it is really a nice thing to be able to blink a led without having to known all the semiconductor’s physics. It seems to me that people here would like to have some kind of selection on who can blink leds, and I am not sure that this is a good thing.
    After my first blink, in my spare time I studied and learned a lot of things, and this actually is a decrease in ignorance, even if I am not an engineer and I will never be.

  15. Good to know that there are options but claiming that setting up AVR programming in Linux is hard is a bit of a stretch. I, having close to zero EE experience:

    1. bought the TinyISP
    2. read this: http://www.evilmadscientist.com/article.php/avrtargetboards
    3. soldered my own target board for tiny2313 (later I did another one including a rs232 serial port).
    4. Installed the avr-gcc and skimmed through some examples
    5. Did some small programs using a text editor and command line tools (avr-gcc, make, avrdude..)
    6. And later found the AVR eclipse plugin, which is nice.

    Overall, I consider starting AVR programming in Linux an easy and straightforward task especially when there are masses of tools, documents and information around.

  16. I have to disagree with the ideas of some who say that it is ignorance to want to use an easy method to program devices. I have an ee degree, I have made silicon chips, I have programmed in a number of languages, and I use gentoo on my desktop, however, I find it much more user friendly to use the arduino interface and ide than to start from scratch using another system. I am glad when things are made simple for the average user, it used to be said, that a rising tide raises all boats. I am not interested in programming my own usart library, there are perfectly good ones out there. The more people we get working with these microcontrollers, the more will dig deeper and learn the more basic languages, but the more we are purist about them, and say that lfs is the only linux, or that hardcore programming is the only way to program, the more we kill interest in them.

  17. The problem with Arduino is the huge amount of assumptions made, and new “concepts” introduced, just about all of them could have easily been avoided.

    * The weird pin numbering.
    * Why call C source code sketches? just confusing.
    * 16MHz crystal assumed and currently very hard to change
    * Many libs assume certain peripherals on certain IO-pins, you mostly need to dig into some lib header file to change these

    There are simple solutions:
    1. Since these so called sketch files are heavily preprocessed anyway, why not just have a macro which defines a clockrate, and changes all affected code?
    2. Same for pins, any lib which is for a hardware peripheral, should *always* be pin-configurable directly from your source code, you shouldn’t need to edit the library.
    3. There could be a preprocessing step which reads fuse-settings from a macro in your sketch.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.