The following code comes from AtTiny serial library that I want to use:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

// change these to use another pin
#define TX_PIN  PB0
#define TX_DDR  DDRB
#define TX_DDR_PIN DDB0

I have no idea which pins to connect. What do these constants mean and where are they documented?

  • On the ATTiny13 PB0 is on physical pin 5.
    – Gerben
    Commented Apr 13, 2019 at 15:36

1 Answer 1


The mapping can be found in the io.h file but also in Arduino core files.

Below is the pin mapping:

  (VCC)-------------1-|VCC   GND|-14------------(GND)
  (D10)-------------2-|PB0   PA0|-13----------(D0/A0)
  (D9)--------------3-|PB1   PA1|-12----------(D1/A1)
  (/RESET)----------4-|PB3   PA2|-11----------(D2/A2)
  (D8)--------------5-|PB2   PA3|-10-------(D3/A3/SS)
  (D7/A7)-----------6-|PA7   PA4|-9---(D4/A4/SCL/SCK)
  (MISO/SDA/D6/A6)--7-|PA6   PA5|-8------(D5/A5/MOSI)

The serial library uses:

#define TX_PIN  PB0

Which is ATtinyX4 Pin #2, or Arduino attiny core digital pin D10 https://github.com/damellis/attiny/blob/master/variants/tiny14/pins_arduino.h.


  • 1
    Question is about ATTiny13
    – Gerben
    Commented Apr 13, 2019 at 15:35
  • 1
    @Gerben No the tag. The actual source code mentioned is ATtinyX4. But in any case the same "lookup" is required. Commented Apr 13, 2019 at 15:40
  • All his other questions are about the 13A. I don't think that library will work on an ATTiny13A. At the very least, the library assumes it runs at 8MHz, while the 13A runs at 9.6MHz. He'd have to change the OCR0A = 103; with something like 123.
    – Gerben
    Commented Apr 13, 2019 at 15:47
  • @Gerben Thanks for pointing that out. I know that the library isn't meant specifically for 13A, but I cannot find anything else, so I decided to try to get that to work. Commented Apr 13, 2019 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.