Arduino Pinout reassignment

Is there an easy way to reassign the IC - board pinouts?
I have see the boards.h and pinouts.h .. not sure
what other files would do this .. but is over my head
at this point ..

The goal is to have the pins in the sketch match the
actual pins on the IC for those of us that create our
own PCB's ...

So .. instead of saying digitwrite 13 .. which is really pin 7
on the chip .. want to just say .. digitalwrite 7

Randy - N2CUA

PS asking in the forums because I get the feeling that perhaps
someone else has already attempted this but my searches
didnt turn up anything ..

The mapping from ports and pins is done in:

hardware/arduino/variants/TYPE/pins_arduino.h

The "TYPE" (standard, mega, leonardo, eightanaloginputs) is specified in the boards.txt file:

uno.build.variant=standard

You could add your own variant called, for example "barechip386P" and map pin numbers to ports and pins any way you like.

To be honest, its more trouble than its worth, you soon get used to what pins are where or you just write to the ports them directly. Print out the pin mapping and forget about it, you will probably find that libraries stop working etc

Duane B

rcarduino.blogspot.com

You can name the pins what you want in the sketch:
byte pin0 = 2;
byte pin1 = 3;
byte pin2 = 4;

for example.
Really has nothing to do with creating the PCB tho.

Pin Mapping was more straightforward up to IDE -0023. In IDE 1.0 it got more complicated, with more files involved, and more changes needed in pins_arduino.h. I wish it was documented, as I am looking to get a couple pins added for a '2560 design I am starting to test.

Per Randy's question, I agree 100% - sure would be nice to be able to use the actual uC pin numbers for the sketch.

I guess I'll continue to do as Duane suggested, just print out a pin-out map and made the conversion there.

This forum has always been very helpful for my projects - thank ya'll again.

73 de Ken H>

KenH:
Per Randy's question, I agree 100% - sure would be nice to be able to use the actual uC pin numbers for the sketch.

I guess I'll continue to do as Duane suggested, just print out a pin-out map and made the conversion there.

This forum has always been very helpful for my projects - thank ya'll again.

73 de Ken H>

You could always just do what CrossRoads said:

Create a header file that creates constant variables with something like PIN1, PIN2, PIN3, etc. and include the header in any sketch you want to give it that functionality.

The way I handled this is to create a schematic symbol for the processor in Cadsoft Eagle and used text on the pins in the symbol which shows the function of each pin - e.g. for the mega processor chip pin 1 is labeled (OC0B)PG5[D4], chip pin 2 is labled (RXD0/PCIN8)PE0[D0] etc. giving the function(s), Port and bit, and Digital (or analog) pin used in the software.

In the software I define each pin with a MEANINGFUL name -

#define UP_BUTTON 6
etc

Makes it easy to do the layout and get the pins straight in the software (and change them when necessary)

Yes, I also assign each pin a meaningful name - RawVoltIn, and stuff like that. The only place I had to remember the uC pins vs Arduino pins is in the very first part of sketch where they are assigned. Once that is done, I never refer to the uC/Arduino pin number again, only the meaningful name. That way it's not such a "big" deal, just felt it would be nice.

Thanks to all for suggestions and ideas.

Ken H>