Arduino environment with ATTiny + Arduino Mini Pro programming *UPDATED, December 7th – 2014*

While I picked up my own car-system for the H0 modelrailroad again, I started with the ATTiny IC’s to control the cars. I’m currently switching from RF to IR. I normally use Microchip PICs in my projects, but because the ATTiny is able to output 40mA on it’s output pins, I will use the ATTiny. The cars will be running on one-cell LiPo batteries. (3.7V, not enough to put 2 high-brightness LEDs in serie, lol)

Because I have a few Arduinos laying around, and with plenty of libraries available, I wanted to use The Arduino IDE and language, to program the ATTiny4313. But the Arduino IDE, normally only supports the Arduino boards itself (Mega,Uno,Leonardo etc … Just to name a few) And even the Arduino mini boards, are way to big to fit in the back of an H0 truck 🙂

These are the steps I followed, to be able to program ATTiny from within Arduino IDE:

1. At the moment of this writing, I’m using Arduino IDE 1.5.8 – Make sure your Arduino IDE is closed.

2. Download the corresponding ATTiny library from

3. Unzip this ZIP-file into your Arduino Sketch folder.
(There is a README included in the ZIP-file, that explains it all)
It’s also necessary to create a boards.txt file. You can simply rename the “prospected boards.txt” to “boards.txt”.
(this will not only give you access to ATTiny2313 & 4313, but also 84,85,44 etc …)

4. Next, openup the example “ArduinoISP” (it’s included in the Arduino IDE) and put it onto an ATMEGA2560.
(you can also use other Arduinos, but you will need to lookup the wiring for step 5, it’s not the same for all Arduino boards !)

5. Use a breadboard, and make sure you connect the following pins: (left are the MEGA pins, right are the ATTIny4313 pins)
also see picture 3
52 => 19
53 => 1
50 => 18
51 => 17
GND => 10
+5V => 20
Also connect  a 10 uF capacitor over GND and RESET on the ATMega.
(watch the polarity, – of the capacitor needs to be connected to GND)

6. Open the “blink LED” example, and change the code to use pin 12. (This corresponds to real pin 16 of the ATTiny4313)
Set your board to “ATTiny4313 at 1 Mhz”.

7. Set your programmer to “Arduino as ISP”, and do “upload with programmer” from the file-menu in the Arduino IDE.

8. Connect a LED with cathode to GND and anode to real pin 16 of the ATTiny4313.
(also put a resistor between the LED and the GND !)

9. If you want to switch to 8 Mhz, select the corresponding “ATTiny4313 at 8 Mhz” as your board, and use “burn bootloader”. We are NOT using any bootloaders, but this will se
the fuses of the ATTiny to the correct speed.
(Note that you do NOT need a crystal, not for the 1 MHz, not for the 8 Mhz, the internal oscillator will be used !)

Note that the PIN usage within Arduino is not the same as the real pin-out of the ATTiny4313. See Picture 2 for the numbering.
Also note that ATTiny2313 & 4313 are almost identical.
(They only have a different ID code and the 2313 comes with 2K memory and the 4313 with 4K of memory)

Update – december 27th – 2014
Today I tried to program an Arduino Mini Pro. I followed my own tutorial from november 27th, 2013, but I got into trouble.
Due to an upgrade of the Arduino IDE, an upgrade of the Silabs drivers for the CP2102 and the fact
that Mac OSX Yosemite only accepts signed drivers, I’m no longer able to use the “programming method” I used to use.
So, time for something different 🙂
Just like programming the ATTiny, I managed to use the same methodology for the Arduino Mini Pro.
Howto connect it for programming, is shown in picture 4 …

This entry was posted in Blog, Electronics, Tutorials. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *