Having got to grips with the ATtiny85 (with help from forum users - much appreciated) and thus been able to build several projects using the tiny85 I now want to undertake a project that requires more I/O than the 85 provides. Sticking with the family the ATtiny84 has PA0 to 7 and PB0 to 3, i.e a total of 12 I/O pins. So my question boils down to how do I differentiate between PA & PB pins when writing sketches using the Arduino IDE?
For example PB2 can be used as an external interrupt whilst PA0 can be used as ADC0; so how do I assign "InterruptPin" to PB2 and "CalibrationPin" to PA0? (InterruptPin & CalibrationPin being the names chosen to have suitable meaning)
A search for attiny84 pinout turns up a number of these type of images. The pin names you're looking for are in brown here.
Thank you for prompt replies. Yes I have studied the datasheet and I am aware of the information that you hace provided. However my question relates to writing the sketch in the Arduino IDE
At the top of the sketch I want to assign pins and I would write:-
int InterruptPin = ? what do I put here to assign PB2?
int CalibrationPin = ? What do I put here to assign to PA0?
In other words how do I differentiate between PBx & PAx when writing the sketch?
Subsequently in I would use the pinMode statements to define these as input pins
I hope this explains my query
Thanks
You are writing Arduino code to run in the ATTINY, so you don't need to be concerned about ports PA, PB etc. You refer to pins by number, in the same way as with other models of Arduino like Uno etc.
To know which physical pin correspond to which Arduino pin number, you first need to know what Arduino Core you are using. This is my preferred Core:
The documentation of the Core will tell you how the Arduino pins corresponded to physical pins:
For example if you want to use physical pin 10, that is Arduino digital pin 3 or analog pin A3.
In your code you would put something like
int CalibrationPin = A3;
With ATTinyCore you can use pin names like PIN_PA0
and PIN_PB2
.
May I thank you all for your replies and suggestions. As a beginner in this field of micro-controllers I clearly need to discover more about "cores" etc. We're off travelling for a few days so will get back to studying shortly!