Phototransistors and Multiplexing

Hi I have been trying to use a CD4067B , CD4097B multiplexer as a DAC. I am attempting to read the voltage across an array of phototransistors by controlling which pin and so which phototransistor I am reading using the arduino's digital output pins. I want to loop the system over so that I can continually read the change it voltage across every phototransistor trough the analogue input pins. I have attached the data sheet for the multiplexer and the code which I have attempted to write. I'm not much of a programmer so I'm not sure if it makes sense. Can anyone help with this?

unsigned long time;
void setup(){
 Serial.begin(9600);
 for (int i=0; i<8; i++){
   pinMode(i,OUTPUT);
   
 } 
   
   
 }
 
 void loop(){
   Serial.print("Time"); 
   time=millis();
  
   int sensorValue = analogRead(A0);  
   float voltage = sensorValue * (5.0/1023.0);
   
   delay(10);
   
         PORTD = B00000111;
         delay(5000);
     PORTD = B00001000;
     delay(5000);
     
     Serial.println(time);
     delay(1000);
     Serial.println(voltage);
     
     Serial.print(time, DEC);    
     Serial.print(",");   
     
     Serial.print(voltage, DEC);     
     Serial.println();                     
 }

multiplexer data sheet.pdf (1.02 MB)

Using both serial I/O pins as digital outputs is a problem.
I'd fix that first.

I'd also use code tags.

Okay thanks, so how would I write this without using the digital outputs as both I/O
I'm haven't done any programming before so this is all very new to me :confused:

Dont use pins 0 or 1. Use two other pins.

Right, first things first.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can review it conveniently and accurately.

Albeit it is not too complex at present, but it may well get more so.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

Until you reply and demonstrate that you understand these points that have been made so far, there is absolutely no point working through the other problems with the code, so I will leave it at that for the present.

Get rid of the floating point math unless you like to waste clock cycles.

Arduino ADC returns an int with 0 to 1023. You want voltage? Why?

I was told by my lecturer that I need a voltage input just to make the multiplexer work and will also need it for each individual phototransistor circuit

In the Arduino, external analog voltages are represented by integers in the range 0 to 1023. That is all you have to work with, so think along those lines.

I need a voltage input just to make the multiplexer work

?