All analog inputs read the same voltage when I activate one of the inputs

I have an IR emitter and IR receiver set up where I bring four IR emitter/receiver pairs into separate analog inputs. I'm trying to read the voltage change that occurs when an IR receiver is blocked from the emitter. I am using the 3v pin as my reference and am using an adafruit SD card shield for data logging. Here is my problem: when I block one receiver with aluminum foil, all of the receivers report the same voltage change. They each have their own analog input, and the only lines the receivers share is the power and ground. Any ideas on how to resolve this issue?

// A simple data logger for the Arduino analog pins

#include <SPI.h>
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"

// how many milliseconds between grabbing data and logging it. 1000 ms is once a second
#define LOG_INTERVAL  1000 // mills between entries (reduce to take more/faster data)

// how many milliseconds before writing the logged data permanently to disk
// set it to the LOG_INTERVAL to write each time (safest)
// set it to 10*LOG_INTERVAL to write all data every 10 datareads, you could lose up to
// the last 10 reads if power is lost but it uses less power and is much faster!
#define SYNC_INTERVAL 1000 // mills between calls to flush() - to write data to the card
uint32_t syncTime = 0; // time of last sync()

// the digital pins that connect to the LEDs
#define redLEDpin 2
#define greenLEDpin 3

// The analog pins that connect to the sensors
#define vccPin0 0                // analog 0
#define vccPin1 1                // analog 1
#define vccPin2 2                // analog 2
#define vccPin3 3                // analog 3
// Analog  Pin  4 is protected   // analog 4 (Protected)
// Analog  Pin  5 is protected   // analog 5 (Protected)
// Digital Pin 10 is protected   // digital 10 (Protected)
// Digital Pin 11 is protected   // digital 11 (Protected)
// Digital Pin 12 is protected   // digital 12 (Protected)
// Digital Pin 13 is protected   // digital 13 (Protected)

//#define BANDGAPREF 14            // special indicator that we want to measure the bandgap

#define aref_voltage 5.0         // we tie 3.3V to ARef and measure it with a multimeter!
//#define bandgap_voltage 1.1      // this is not super guaranteed but its not -too- off

// Choose the correct chip to get the time right!
//RTC_DS1307 RTC; // define the Real Time Clock object
RTC_PCF8523 RTC;

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
{
  Serial.print("error: ");
  Serial.println(str);

  // red LED indicates error
  digitalWrite(redLEDpin, HIGH);

  while(1);
}


/*****************************************************
 *                  SETUP
 *
 ****************************************************/
void setup(void)
{
  Serial.begin(9600);
  Serial.println();

  // use debugging LEDs
  pinMode(redLEDpin, OUTPUT);
  pinMode(greenLEDpin, OUTPUT);

  // initialize the SD card
  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    error("Card failed, or not present");
  }
  Serial.println("card initialized.");

  // create a new file
  char filename[] = "LOGGER00.CSV";
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!
    }
  }

  if (! logfile) {
    error("couldnt create file");
  }

  Serial.print("Logging to: ");
  Serial.println(filename);

  // connect to RTC
  Wire.begin();
  if (!RTC.begin()) {
    logfile.println("RTC failed");
    Serial.println("RTC failed");
  }

  logfile.println("time, datetime, V1, V2, V3, V4");
  Serial.println("time, datetime, V1, V2, V3, V4");

  // If you want to set the aref to something other than 5v
  //analogReference(EXTERNAL);
}


/*****************************************************
 *                  LOOP
 *
 ****************************************************/
void loop(void)
{
  DateTime now;    // Creating the DateTime object 'now'

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));

  // turning the green LED ON
  digitalWrite(greenLEDpin, HIGH);

  // log milliseconds since starting
  uint32_t m = millis();
  logfile.print(m/1000.0);           // milliseconds since start
  logfile.print(", ");
  Serial.print(m/1000.0);         // milliseconds since start
  Serial.print(", ");

  // fetch the time
  now = RTC.now();

  // log time
  logfile.print(now.month(), DEC);
  logfile.print("/");
  logfile.print(now.day(), DEC);
  logfile.print("/");
  logfile.print(now.year(), DEC);
  logfile.print(" ");
  logfile.print(now.hour(), DEC);
  logfile.print(":");
  logfile.print(now.minute(), DEC);
  logfile.print(":");
  logfile.print(now.second(), DEC);

  Serial.print(now.month(), DEC);
  Serial.print("/");
  Serial.print(now.day(), DEC);
  Serial.print("/");
  Serial.print(now.year(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(":");
  Serial.print(now.minute(), DEC);
  Serial.print(":");
  Serial.print(now.second(), DEC);

  // Pre-reading the analog pins
  analogRead(vccPin0); // cage one
  analogRead(vccPin1); // cage two
  analogRead(vccPin2); // cage three
  analogRead(vccPin3); // cage four
  delay(10);

  // Reading again and storing data in variables
  int vcc0Reading = analogRead(vccPin0);
  int vcc1Reading = analogRead(vccPin1);
  int vcc2Reading = analogRead(vccPin2);
  int vcc3Reading = analogRead(vccPin3);
  delay(10);

  // converting that reading to voltage, for 3.3v arduino use 3.3, for 5.0, use 5.0
  float voltage0 = vcc0Reading * aref_voltage / 1024;
  float voltage1 = vcc1Reading * aref_voltage / 1024;
  float voltage2 = vcc2Reading * aref_voltage / 1024;
  float voltage3 = vcc3Reading * aref_voltage / 1024;

  logfile.print(", ");
  logfile.print(voltage0,4);
  logfile.print(", ");
  logfile.print(voltage1,4);
  logfile.print(", ");
  logfile.print(voltage2,4);
  logfile.print(", ");
  logfile.print(voltage3,4);
  logfile.println();

  Serial.print(", ");
  Serial.print(voltage0,4);
  Serial.print(", ");
  Serial.print(voltage1,4);
  Serial.print(", ");
  Serial.print(voltage2,4);
  Serial.print(", ");
  Serial.print(voltage3,4);
  Serial.println();


  // Turn the green LED OFF
  digitalWrite(greenLEDpin, LOW);

  // Now we write data to disk! Don't sync too often - requires 2048 bytes of I/O to SD card
  // which uses a bunch of power and takes time
  if ((millis() - syncTime) < SYNC_INTERVAL) return;
  syncTime = millis();

  // blink LED to show we are syncing data to the card & updating FAT!
  digitalWrite(redLEDpin, HIGH);
  logfile.flush();
  digitalWrite(redLEDpin, LOW);
}
 // Pre-reading the analog pins
  analogRead(vccPin0); // cage one
  analogRead(vccPin1); // cage two
  analogRead(vccPin2); // cage three
  analogRead(vccPin3); // cage four
  delay(10);

What's the point here? You're supposed to do this when switching the multiplexer in free running mode. Even if you follow the most paranoid misunderstandings you would do this whenever you switch pins. There's no point in reading them and throwing away the results if you're not coming back to read the exact same pin next.

float voltage0 = vcc0Reading * aref_voltage / 1024;

Since everything on the right is int, this gets done with int math. You won't get a floating point result.

Make it like this instead:

float voltage0 = vcc0Reading * aref_voltage / 1024.0;

The pre-reading was suggested by a friend to get more stable readings (I don't entirely understand how that was supposed to help myself). I tried omitting the prereading lines and made the suggested change to the float points. The problem still persists. I've attached a photo of the serial monitor output to help. At time point 6, I covered one of the receivers and you can see that all of them change, which is not desired.

Can you post a wiring diagram? Hand drawn is fine. Please no Fritzing pics with components that aren't the real thing and wires all the same color. Just draw one.

Dwood1003:
The pre-reading was suggested by a friend to get more stable readings (I don't entirely understand how that was supposed to help myself).

But if you're going to do it then you need to do one pin at a time. You can't read all four and then read all four. Read 0 and throw away then read 0, then read 1 and throw away and then read 1, etc...

I have a detailed Fritzing one that is color coded, would that be okay? I'll start drawing one just in case though.

Here is the hand drawn one.

That only shows one receiver. I thought there were 4 and we were wondering why they were interfering.

If your Fritzing only shows things that you actually have and all the wires aren't the same color then go ahead and post it. If you wonder why we hate Fritzing so much check this thread. If you're not one of these offenders then it will probably be OK. Just make sure it is readable by someone who isn't there looking at the real thing next to it.

Here is the Fritzing. I only have two pairs drawn on here, but the next two would connect the same way (using A2 and A3 respectively).

Attachment didn't make it.

I had to change the file type. Post is updated now.

What types of IR emitters and receivers are you using? Post links to the data sheets.

Do you have the IR emitters and receivers wired the right way around? They won't work otherwise.

Check your circuit and your code with just one IR receiver. If it is working, the room lighting should be enough to activate the receiver.

Unfortunately, I have Sunkee ones I purchased through amazon and there is no data sheet available. The receiver is a phototransistor. I have them set up correctly. When I use one, I get the expected response.

Dwood1003:
I'm trying to read the voltage change that occurs when an IR receiver is blocked from the emitter.

So a beam-break sensor.

Why don't you use digital pins for that.
Leo..

Try something like this, which does not create so many wasted variables:

// Reading again and storing data in variables

  int junk = analogRead(vccPin0);
  float voltage = ((float) analogRead(VccPin0))*aref_voltage / 1024.;
  logfile.print(voltage,4);
  logfile.print(", ");

  junk = analogRead(vccPin1);
  voltage = ((float) analogRead(VccPin1))*aref_voltage / 1024.;
  logfile.print(voltage,4);
  logfile.print(", ");

  junk = analogRead(vccPin2);
  voltage = ((float) analogRead(VccPin2))*aref_voltage / 1024.;
  logfile.print(voltage,4);
  logfile.print(", ");

  junk = analogRead(vccPin3);
  voltage = ((float) analogRead(VccPin3))*aref_voltage / 1024.;
  logfile.print(voltage,4);
  logfile.println();
1024.;

It's cool that you know you don't need the 0 on the end, but it really help readability to put it there. And it doesn't cost you anything. Most of us have hard drives large enough to hold the code even with the few extra characters.

float voltage = ((float) analogRead(VccPin0))*aref_voltage / 1024.0;

Otherwise it is easy to overlook that decimal.