JUGmobile:
HWB pin:
I haven't researched HWB pin yet, so any comments below are welcome. Some day I will add instructions how to use HWB pin as I/O pin.
I've not tried to use that pin, so this is theoretical: That pin is used as an input for the bootloader, and is tied low through a 10K resistor. If you try to use that as a general purpose input, it's possible that the external hardware could be driving that line in a high state while you are resetting, and that could change the behavior of the bootloader. If you want to use that pin, it's best to use it as an output, in a circuit that won't be affected by having a 10k pulldown resistor on it. (Not with an AVR processor, but I have run into problems like that trying to use a boot mode pin on other processors - it just isn't reliable to use such a pin as an input, it will come back to bite you eventually.)
There doesn't appear to be any support for that particular pin in the Leonardo's pin definitions, so you will probably have to resort to accessing the DDRE and PORTE registers directly to set it up as an output and set its output state.
GrahamPrattWyalong:
Hi, I see in the picture that there are more Acc connected pins, I have read this in different places also..... Problem I am having is working out how to reassign a digital pin, say pin 26 (pd6t1/0c4d/adc9).
You say Acc, but I assume you mean ADC, and I guess you are saying you want to use pin 26 as another analog input? The file hardware/arduino/avr/variants/leonardo/pins_arduino.h in your Arduino program folder defines all of the pins It has this section:
// Mapping of analog pins as digital I/O
// A6-A11 share with digital pins
static const uint8_t A0 = 18;
static const uint8_t A1 = 19;
static const uint8_t A2 = 20;
static const uint8_t A3 = 21;
static const uint8_t A4 = 22;
static const uint8_t A5 = 23;
static const uint8_t A6 = 24; // D4
static const uint8_t A7 = 25; // D6
static const uint8_t A8 = 26; // D8
static const uint8_t A9 = 27; // D9
static const uint8_t A10 = 28; // D10
static const uint8_t A11 = 29; // D12
So, while I've not tried it, it looks like all you might have to do to use pin 26 (D12) as an analog input is to use pin A11 in your analog read call. Same for the other pins, they look to be mapped as A6 through A11.
This seems to be confirmed later in the file, where the An numbers are mapped to analog hardware channels:
const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
7, // A0 PF7 ADC7
6, // A1 PF6 ADC6
5, // A2 PF5 ADC5
4, // A3 PF4 ADC4
1, // A4 PF1 ADC1
0, // A5 PF0 ADC0
8, // A6 D4 PD4 ADC8
10, // A7 D6 PD7 ADC10
11, // A8 D8 PB4 ADC11
12, // A9 D9 PB5 ADC12
13, // A10 D10 PB6 ADC13
9 // A11 D12 PD6 ADC9
};
A6 through A11 do have ADC hardware channel numbers assigned, and the comments match up with the pin names/functions mentioned in the diagram above. So, simply try using those analog pin names, and it should just work.