0

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_PORT PORTB
#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?

Tomáš Zato
  • 340
  • 5
  • 17

1 Answers1

1

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

Below is the pin mapping:

                        ATtinyX4
                      +----U----+
  (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.

Cheers

Mikael Patel
  • 7,989
  • 2
  • 16
  • 21