Feasible to use an ATTiny?

I'm looking for a pointer on how to do something rather than asking people to debug software or solve a problem for me - so here goes -

Having prototyped a couple of interesting projects for use on a model railway, I now want to "miniaturise" what I've done and, after a bit of scooting around on the net, I think I've found a solution which goes roughly as follows

  1. Build my hardware onto a bit of circuit board
  2. Include a DIL socket to accept an ATTiny
  3. Download the sketches (developed on the Uno) onto ATTiny using the Arduino as a platform (there seem to be a couple of Internet resources suggesting this can be done)
  4. Plug the ATTiny into the DIL socket onto my project board

... and off we go - then, if for example I'm not happy with the result, remove the ATTiny, reprogram it
and plug it back in

This approach, if feasible, would allow me to cheaply build programmable modules that will fit into e.g. n-gauge buildings and suchlike. And provide a foundation for more ambitious projects than simulating burning buildings, arc welders and suchlike.

Am I barking up the wrong tree?

Would I be able to simply transfer C code developed on the Arduino straight onto the ATTiny?

I did consider PICAXE, however I wasn't too keen on forking out the cost of a couple of Arduinos (or a bundle of Funduinos!) on the development kit, nor having to learn another programming language to do it - I'd rather just keep practising my newly-learned C skills!

You may have problems converting sketches developed on Arduino into ATTinys - there are slight differences that may or may not matter. Arduino core is trying to mask this differences but it cannot be 100% effective.

ATTiny has less instructions that need to be emulated - most notably multiplying in ATMega (Uno's chip) is takes 2 cycles but in ATTiny need use bit shifts and additions to multiply which may take longer. Calculations can be fast enough on ATMega but not on ATTiny. ATMega has more peripherals (timers, USART, SPI and TWI module) which some ATTinys have and some doesn't, depending on type. Some ATTinys (ATTiny2313) doesn't have ADC! Arduino board includes many external support circuitry such as filtering caps, crystal/ceramic resonator. Bare ATTiny doesn't have any of those unless you add it.

All of above can be fixed if you know about it but generally you cannot take a sketch from Uno and upload it to ATTiny - it may or may not work. You may try and see.

I personally try ideas for small projects on Uno in Arduino IDE to see if it works and then write it properly on lower level in Atmel Studio in C for the ATTiny. It is not very productive way but I do it for fun and not for money and I enjoy it.

Thanks for the response, Smajdalf, I've since found some interesting information on the Hobbytronics web site, so I guess the way forward is to suck it and see, and if it doesn't work then follow a similar route to yours.

I have found a list of supported Arduino IDE commands (a subset), and for my first simple projects they should do the job, then I can look at the Atmel studio. All good fun and I can get the bits cheaply enough!

Add this to Arduino IDE

will let you program for the Attiny with no doubts as to what will work or not.

You can plug a part in & out to program in, or put a header on the board that connects to the programming pins and just plug a Programmer on to the board when you have new code to download.

Thanks for the input Crossroads, Smajdaf.

Attinys arrived this morning, might give this a go amongst other things to see if it works Smart | Connected | Secure | Microchip Technology - interesting note about importing Arduino code into C++.

About to have fun - I hope!

Cheers - Richard