Why do i only read a value from 1 of 4 multiplexed analog signals?

I have 4 infrared phototransistors and i want to read all of them using one analog input. I set up my code and something weird is going on, the third PT is working perfectly normal, but if i want to print out the value of any other, they're zero. Why is one working but not the others?

My code:

int val1;
int val2;
int val3;
int val4;
int PT1 = 2;
int PT2 = 3;
int PT3 = 4;
int PT4 = 5;
int t = 5;

void setup() 
{
  Serial.begin(9600);
  pinMode(0, INPUT);
  pinMode(PT1, OUTPUT);
  pinMode(PT2, OUTPUT);
  pinMode(PT3, OUTPUT);
  pinMode(PT4, OUTPUT);
}

void loop() 
{
  digitalWrite(PT1, HIGH);   // give power to the first PT
  val1 = analogRead(0);     // check the voltage at the first PT
  delay(t);                       // give it some time to read
  digitalWrite(PT1, LOW);   // cut power to the first PT
  digitalWrite(PT2, HIGH);  // give power to the second PT
  val2 = analogRead(0);    // read
  delay(t);                       // wait
  digitalWrite(PT2, LOW);   // repeat 
  digitalWrite(PT3, HIGH);
  val3 = analogRead(0);
  delay(t);
  digitalWrite(PT3, LOW);
  digitalWrite(PT4, HIGH);
  val4 = analogRead(0);
  delay(t);
  digitalWrite(PT4, LOW);
  Serial.println(val3);
  delay(250);
}

My circuit: just a basic voltage divider

if you cant see that, here's a link

http://postimg.org/image/a4zgnv8k9/

Sorry for the crude diagram made in paint, but it's the best i could do with what i have on my laptop

Also, if you could tell me how to print all 4 values on one line, that would be helpful. i already tried Serial.println(val1 + ", " + val2 + ... and so on);

Is only one phototransistor illuminated at any time?
You could effect an R/2R DAC with some additional components

Also, if you could tell me how to print all 4 values on one line, that would be helpful. i already tried Serial.println(val1 + ", " + val2 + ... and so on);

Serial.print(val1,DEC);
Serial.print(" "); // gap
Serial.print(val2,DEC);
Serial.print(" "); // gap
Serial.print(val3,DEC);
Serial.print(" "); // gap
Serial.println(val4,DEC);

BTW, your "PTs" aren't multiplexed, they're just in parallel.

all of them are getting about the same amount of light at all times.
As for using an R/2R DAC, im trying to tune all of them with a single potentiometer and the smallest number of components possible. Eventually i want to scale this up to 338 phototransistors. But if that's to only way to go ill do it. But i think the problem is in the code. since i can read them all individually but only one while multiplexed

What makes them not multiplexed? im reading 4 of them with a single input by switching between them really fast. If they were just in parallel all the pins would be HIGH at all times and i would get the same value for all the analog reads

Additional Details: It may not be a normal matrix, but it's still multiplexed. I could use 2 digital outputs ans 2 analog inputs to make it more like a matrix, but 4 outputs and 1 input is just another shape. Im doing it this way because i have way more than enough digital outputs and a limited number of analog inputs

griffin175:
all of them are getting about the same amount of light at all times.

OK, I see what you’re trying to do better now.
Tried it with two? Tried taking a couple of reading in succession?
Is everything printing on one line the way you wanted?

I removed all the delays and the readings are a lot more smooth, but still only getting one.

Updated Code:

int val1;
int val2;
int val3;
int val4;
int PT1 = 2;
int PT2 = 3;
int PT3 = 4;
int PT4 = 5;

void setup() 
{
  Serial.begin(9600);
  pinMode(0, INPUT);
  pinMode(PT1, OUTPUT);
  pinMode(PT2, OUTPUT);
  pinMode(PT3, OUTPUT);
  pinMode(PT4, OUTPUT);
}

void loop() 
{
  digitalWrite(PT1, HIGH);  // give power to the first PT
  val1 = analogRead(0);     // check the voltage at the first PT
  digitalWrite(PT1, LOW);   // cut power to the first PT
  digitalWrite(PT2, HIGH);  // give power to the second PT
  val2 = analogRead(0);     // read
  digitalWrite(PT2, LOW);   // repeat 
  digitalWrite(PT3, HIGH);
  val3 = analogRead(0);
  digitalWrite(PT3, LOW);
  digitalWrite(PT4, HIGH);
  val4 = analogRead(0);
  digitalWrite(PT4, LOW);
  Serial.print(val1,DEC);
  Serial.print(",  ");  
  Serial.print(val2,DEC);
  Serial.print(",  ");  
  Serial.print(val3,DEC);
  Serial.print(",  ");  
  Serial.println(val4,DEC);
}

It's printing the info just like i want it, but i thought there was a way to do it with a single println rather than one for every piece of information. But thats not a problem. Still getting data from just one, ill see if i can cut it down to only 2

Ok, now feel really dumb. i only had the one signal going into the analog input. the wire i had connecting all the others was in a bad hole on the breadboard. But my problems arent over yet. im getting values for all of them and they're all getting about the same amount of light, but the values get smaller as it goes down the chain of transistors. (116, 83, 65, 36) are the values im getting, but they should all be around 116. i dont think theres a significant drop between them, theyre connected really closely

griffin175:
It's printing the info just like i want it, but i thought there was a way to do it with a single println rather than one for every piece of information.

Serial.println
is different from
Serial.print (no ln)
Serial.println makes a carriage return (instead of using "\r\n")
You could make a string of your val1-4 and print that, likely no savings there.