loading
So there I was, browsing eBay, looking for some cheap deals on Atmel chips when i came across a pair of ATTiny13 chips for £2.50. I just had to have them! After all, how hard can it be?

I needed a small chip to read servo signals from a hobby RC Receiver and control a laser output.

Once they arrived it dawned on me that I actually had no idea how to program these little chips. Dom and I spent hours trying various ways of ATTiny programming we found online with no luck. It was only until he left I sat down at my computer and found Tekstop's tutorial on 'Tiny programming that I had any success. With a couple of modifications to his files you will be up and programming these low price chips in no time!

Step 1: Connecting an ATTiny for Programming

Watch the video:


Connect your ATTiny13A to your arduino following the diagram below
Arduino pin 13 - ATTiny pin 7
Arduino pin 12 - ATTiny pin 6
Arduino pin 11 - ATTiny pin 5
Ardunio pin 10 - ATTiny pin 1
Arduino +5v      - ATTiny pin 8
Arduino GNd    - ATTiny pin 4

Optional:
GND - negative side of LED
ATTiny pin 3 - resistor (250 ohm) - positive side of LED
 

ATTINY13A Datasheet: http://www.atmel.com/Images/doc8126.pdf
Arduino ISP info: http://arduino.cc/en/Tutorial/ArduinoISP

Step 2: Setting Up the IDE

  • Open the arduino IDE and connect your Arduino
  • Go to file > Examples > ArduinoISP
  • Check you have the correct board & port selected (Tools > Board/Serial Port)
  • Press the upload button
This will program your arduino board to be used as an ISP (in system programmer)
  • Once complete, close the IDE
We now need to set up the IDE to recognise our ATTiny13A as an arduino compatible chip
  • Download and extract this file: https://github.com/tekstop/attiny/tree/Arduino1
  • Copy the folder "attiny" from the extracted ZIP to the /hardware/ folder in your arduino IDE installation directory
We then need to offset the clock speed (not a very elegant solution, but i'm working on it!):
  • Open Hardware/attiny/boards.txt
  • Scroll to the bottom of the file, this last few lines contains the data relevant to our chip
  • Change "attiny13.build.f_cpu=9600000L" to "attiny13.build.f_cpu=1000000L"
This will correct delay times etc.
  • Open the Arduino IDE again
  • Go to Tools>Board and select "ATtiny13 (internal 9.6 MHz clock)"

Step 3: Programming

You are now all set to upload your sketch to the attiny13a, make good use of its 1024 bytes of internal memory! ;)
  • Open the IDE
  • Click File>Examples>Basic>Blink
  • Change line 11 from "pinMode(13, OUTPUT);" to "pinMode(4, OUTPUT);"
  • Change line 15 from "digitalWrite(13, HIGH);" to "digitalWrite(4, HIGH);"
  • Change line 17 from "digitalWrite(13, LOW);" to "digitalWrite(4, LOW);"
  • Click File>Upload using programmer
The IDE should now upload the sketch to your chip via your ArduinoISP programmer!
Once this is complete (~5 seconds) your LED should start blinking with a 1 second interval

To address pins in the Arduino IDE you should use their PB number from the diagram below (EG Pin1 = PB1 etc..)

If all you wanted to do was learn to program your chip, then congratulations! You are done!
If you would like to build a RC Servo Interpreter then keep reading.

Step 4: Building the Servo Interpreter

Check out my YouTube video below for an easy walk through of how to program the software

Code is available in attached text file.

Connect the LED and resistor in exactly the same way as Step 1 states for testing purposes
If you use a relay it should be rated at 5V for the coil.
Connect the coil between pin 4 and GND
If using a relay you should also use a diode to protect the ATTiny from EMF by wiring it across the relay coil, negative(white band) side connected to pin 4.

Step 5: Testing 123


Thanks for reading guys! 
Happy Hacking!
i made it<br>its so great and cheap for projects<br><br>careful this :<br>your arduino ISP have to be 1.0.x version<br>and you have to edit &quot;wiring.c&quot; file<br>
<p>Amkoshesh below is right - use the McUdude libraries to fix the problems with both the clock speed, and with the proper additinon on the ATTiny13A board to the Arduino 1.8.1 IDE. </p><p>Worked for me, using a SparkFun RedBoard as the programmer, with the same wiring layout as ooda55 details above. </p><p><a href="https://github.com/MCUdude/MicroCore" rel="nofollow">https://github.com/MCUdude/MicroCore</a></p>
<p><a href="http://forum.arduino.cc/index.php?topic=453093.0" rel="nofollow">http://forum.arduino.cc/index.php?topic=453093.0</a></p><p>My problem was solved</p>
<p>aaaallllllllloooooooooooooooooooooooooooooooooooooooooooooooooooo</p><p>even i had the same problem</p><p>Arduino: 1.8.1 (Windows 10), Board: &quot;ATtiny13 (internal 9.6 MHz clock)&quot;</p><p>The current selected board needs the core 'arduino:arduino' that is not installed.<br>Detecting libraries used...<br>recipe.preproc.macros pattern is missing</p><p>Error compiling for board ATtiny13 (internal 9.6 MHz clock).<br>The current selected board needs the core 'arduino:arduino' that is not installed.</p><p>Do you have a comment?</p>
<p>I just try &quot; verify &quot;</p>
<p>hi</p><p>Who can advise me about this problem</p><p>recipe.preproc.macros pattern is missing</p><p>Error compiling for board ATtiny13 @ 9.6MHz (interne 9.6 MHz clock).</p>
<p>how to add libry for attiny 13A</p>
<p>can i make this with arfuino pro mini</p>
<p>can i make this with arfuino pro mini</p>
<p>Can i make this with arduino pro mini?</p>
<p>I had the same timing issue in the blink sketch, solved it by choosing from the Arduino IDE (v1.0.6) board selection submenu &quot;Attiny13A standalone with 1.2MHz&quot; clock. </p>
<p>I found out that the error &quot;avrdude: please<br> define PAGEL and BS2 signals in the configuration file for part <br>ATtiny13&quot; does not affect the programming. That went fine.</p><p>The delay in the blink-sketch is another issue: 1 second lasts like 5 seconds in the ATtiny13A. </p>
<p>Everything went very well, except programming the ATtiny13:</p><p>&quot;avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny13&quot;</p><p>what does that mean? thanks</p>
Can the Attiny13(A) run at 8 MHz? I want to use the softwareserial library on it but it needs 8MHz (or other like 16MHz, correct me if I'm wrong.)
<p>Hi, </p><p>Thanks for the tut, it worked great on arduino 1.6.5 and a Nano Arduino. </p><p>I also want to use the softwareserial library on the ATtiny13A but i can't. do your serial communication work? Thanks.</p>
<p>Unless you use an external oscillator, the Attiny13 runs at unusual frequencies (like 128K, 1.2MHz, 2.4MHz, 4.8MHz and 9.6MHz) </p><p>The software serial library won't work without modification</p>
<p>That's beautiful mate!</p><p>I'm using that to control light and some sensors on my small RC airplanes, way cheaper and lighter than a arduino mini pro or a attiny85 :)</p><p>Cheers!</p>
<p>Informative</p>
<p>Interesting, I followed your ibble and had no succes. LED on the blink program just doesnt blink, stays high.<br>It had been very long since i programmed Attiny13, usually I do the 85, but went back to a core I described 3 years ago : <a href="https://www.instructables.com/id/Installing-Attiny13-core-files/?utm_source=base&utm_medium=related-instructables&utm_campaign=related_test" rel="nofollow"> https://www.instructables.com/id/Installing-Attiny...</a></p><p>and that worked. Dont understand why your core doesnt. I am using IDE 1.06.<br>Also, I first &quot;burn the bootloader&quot; to set the right speed.<br>Any idea what I could be doing wrong in using your core?</p>
<p>here's the solution: <a href="https://tekstop.wordpress.com/2011/12/30/programming-attiny13-using-arduino-isp-and-all-the-hacking-involved/" rel="nofollow">https://tekstop.wordpress.com/2011/12/30/programmi...</a></p><p>however even tho the led blinks its off time, the delay is a little less than 1 second...</p>
<p>ah yes, that would do it... anyway, already moved on to 1.6.4 and using adapted Smeezekitty core for that</p>
<p>Thanks :-) I am not sure if that is a solution. Anyway, a lot can happen in a month: I just stuck to Smeezekitty's core and updated that for IDE 1.6.x and that works fine<br>Yes, I know it is off in timing a bit but that is no problem for me.<br></p>
<p>hello people Im having trouble programming my attiny13 with my knock off arduino</p><p>I have got everything to work fine until I tried programming this chip im using version 1.6.4 arduino IDE I downloaded the software for the attiny13 I keep getting error messages ?</p>
<p>which error messages?</p>
<p>I'm trying to program an attiny13 soic using an Uno as a isp. I'm following this instructable, but I keep getting the error &quot;avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)&quot;</p><div> <br><div>I replaced Arduino 1.5 with 1.0.6. I'm using a soic clip, and have repositioned it 1000 times in case it's not connecting. <p>Any idea what I might be doing wrong? I've rechecked the connections a bunch of times.</p></div></div>
Hi glassgiant,<br><br>Check you uploaded the Arduino ISP skectch successfully, and that you have the right board, programmer (arduino as ISP) and COM port selected.
Thanks, I stupidly had the wrong programmer selected. My project is working now!
To get correct timing you need to change 9600000L in the boards.txt to 1200000L<br>(It is 1/8 of 9600000)<br>Then the delay time will be good.
<p>I agree, that should be the solution here but when you check the timing with a 50hz blink example (10ms LOW, 10ms HIGH) you will see that the timing is still not right. It will be about 57Hz in stead of 50Hz.</p><p>An alternative solution is to write the lower fuse to 0x7a (default is 0x6a). That will disable the <strong>divide clock by 8</strong> option and the timing will be near perfect!</p>
<p>Nice tutorial, by my led comes on but won't blink...</p>
<p>The led lights on but not blink! </p><p>Did you find the error?</p>
<p>Is it possible to use this setup to duplicate the data from another ATTiny13A?</p>
adding a 10uf capacitor between reset and ground solves the stk500 problem. <br>
I was wondering, have you ever received a &quot;avrdude: stk500_recv(): programmer is not responding&quot; error? I keep receiving it.
Did you load the Arduino ISP sketch successfuly? <br>And are you connected to the correct com port?

About This Instructable

89,274views

104favorites

License:

More by ooda55:Programming an ATTiny13A using Arduino & servo interpreter Super Simple & Super Cheap DIY UPS/CCTV system from recycled batteries! USB Robot 
Add instructable to: