ATmega2560 Analogue inputs

Hi
I am trying to use A0-7 as digital inputs and have set PORT F accordingly but A7 constantly returns 1 even when pin A7 is forced to ground.
Is the that channel used by Arduino software or have I just got a duff chip on my board?
Thanks

clayender:
Hi
I am trying to use A0-7 as digital inputs and have set PORT F accordingly but A7 constantly returns 1 even when pin A7 is forced to ground.
Is the that channel used by Arduino software or have I just got a duff chip on my board?
Thanks

Should work, but without seeing your code that doesn't work it's hard to say why you are having problems.

Lefty

retrolefty:

clayender:
Hi
I am trying to use A0-7 as digital inputs and have set PORT F accordingly but A7 constantly returns 1 even when pin A7 is forced to ground.
Is the that channel used by Arduino software or have I just got a duff chip on my board?
Thanks

Should work, but without seeing your code that doesn't work it's hard to say why you are having problems.

Lefty

Looks like the problem is the Arduiono software....using Serial.println(variable,BIN) this routine doesn't write the MSBit to the monitor if it is logic 0

i.e. HEX fffff = BIN display 1111111111111111 but HEX 7fff = BIN display 111111111111111 instead of 0111111111111111
same problem for byte, char or int conversions......the HEX OCT and DEC work fine

The Print class prints the values binary using this method:

size_t Print::printNumber(unsigned long n, uint8_t base) {
  char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
  char *str = &buf[sizeof(buf) - 1];

  *str = '\0';

  // prevent crash if called with base == 1
  if (base < 2) base = 10;

  do {
    unsigned long m = n;
    n /= base;
    char c = m - base * n;
    *--str = c < 10 ? c + '0' : c + 'A' - 10;
  } while(n);

  return write(str);
}

As you can see, it stops adding characters as soon as there are only zeros left, so leading zeros are omitted. Count the ones, in the first case you get 16, in the second case you get 15.

Yes I noticed that. Not very helpfull having the output length changing when you are trying to watch specific bits changing.
Guess I'll just have to write my own routine that outputs the condition of ALL bits.

A binary number is not the same as a bit display. The binary number is usually written without leading zeros as you do with decimal numbers.