Skip to main content
added 2 characters in body
Source Link
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  LED "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR

// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 Arduino library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES.  
    
  for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //edited as per @Gerben. thanks so much

    //get an individual sensor reading from IR receiver/opAmp mux, store it in a variable 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[i] = recv_state[i];

} //end for(i...) loop
    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      //
      
       for (int x = 0; x < ledCount; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or if reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 Arduino library - update() clocks the chips
            // move update(); outside the for(x...) loop for speed?
        Tlc.update();
        delay(10);
      
      } //end For(x..) Loop

}//endMainLoop
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  LED "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR

// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 Arduino library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES.  
    
  for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //edited as per @Gerben. thanks so much

    //get an individual sensor reading from IR receiver/opAmp mux, store it in a variable 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[i] = recv_state[i];

} //end for(i...) loop
    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      //
      
       for (int x = 0; x < ledCount; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or if reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 Arduino library - update clocks the chips
            // move update(); outside the for(x...) loop for speed?
        Tlc.update();
        delay(10);
      
      } //end For(x..) Loop

}//endMainLoop
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  LED "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR

// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 Arduino library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES.  
    
  for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //edited as per @Gerben. thanks so much

    //get an individual sensor reading from IR receiver/opAmp mux, store it in a variable 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[i] = recv_state[i];

} //end for(i...) loop
    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      //
      
       for (int x = 0; x < ledCount; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or if reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 Arduino library - update() clocks the chips
            // move update(); outside the for(x...) loop for speed?
        Tlc.update();
        delay(10);
      
      } //end For(x..) Loop

}//endMainLoop
deleted 53 characters in body
Source Link
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  LED "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR
int i;
int x;
// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940  - tlc.set(dsply_state[x], 4000) ...or... tlc.set(dsply_state[x], 0)    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 Arduino library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
  /  // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES. Needs help 
    
  for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //need lotsa help here getting to each of the individual pixel readings

    //edited as per @Gerben. Ithanks think....so much

    //get an individual sensor reading from IR receiver/opAmp mux, store it in a variable?? 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[x]dsply_state[i] = recv_state[i];

} //end for(i...) loop
    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      //
      
       for (int x = 0; x <=< dsply_state.length;ledCount; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or if reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 Arduino library - update clocks the chips
            // move update(); outside the for(x...) loop for speed?
        Tlc.update();
        delay(10);
      
      } //end For(x..) Loop

}//endMainLoop
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR
int i;
int x;
// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940  - tlc.set(dsply_state[x], 4000) ...or... tlc.set(dsply_state[x], 0)    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
  /  // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES. Needs help 
    for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //need lotsa help here getting to each of the individual pixel readings

    //edited as per @Gerben. I think....

    //get an individual reading from IR receiver/opAmp mux, store it in a variable?? 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[x] = recv_state[i];


    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      
       for (int x = 0; x <= dsply_state.length; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 library - update clocks the chips
        Tlc.update();
        delay(10);
      
      } //end For Loop

}//endMainLoop
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  LED "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR

// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 Arduino library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES.  
    
  for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //edited as per @Gerben. thanks so much

    //get an individual sensor reading from IR receiver/opAmp mux, store it in a variable 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[i] = recv_state[i];

} //end for(i...) loop
    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      //
      
       for (int x = 0; x < ledCount; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or if reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 Arduino library - update clocks the chips
            // move update(); outside the for(x...) loop for speed?
        Tlc.update();
        delay(10);
      
      } //end For(x..) Loop

}//endMainLoop
edited code as per both @gerben and @gammon
Source Link
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR
int i;
int x;
// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940  - tlc.set(dsply_state[x], 4000) ...or... tlc.set(dsply_state[x], 0)    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
  /  // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES. Needs help 
    for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b1000000b0100000);    
    digitalWrite(M_S0, i & 0b0100000b0010000);
    digitalWrite(S_S3, i & 0b0010000b0001000);       
    digitalWrite(S_S2, i & 0b0001000b0000100);
    digitalWrite(S_S1, i & 0b0000100b0000010);
    digitalWrite(S_S0, i & 0b0000010b0000001);
    
    delay(2);

    //need lotsa help here getting to each of the individual pixel readings

    //edited as per @Gerben. I think....

    //get an individual reading from IR receiver/opAmp mux, store it in a variable?? //should this be INSIDE the for loop that pushes the readings into recv_state?

     int IRstate = analogRead(InputFromMux);

     //push individual readings into recv_state array. Maybe different code?
     
    for (int x=0; x<= ledCount; x++){
     
        //populate receiving array with a reading
        IRstaterecv_state[i] = recv_state[x];IRstate;
    
        //populate display array for tlc5940 to push out
        recv_state[x]dsply_state[x] = dsply_state[x];recv_state[i];

    } //endFirstForLoop

    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      
       for (int x = 0; x <= dsply_state.length; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 library - update clocks the chips
        Tlc.update();
         delay(10);
      
      } //end For Loop

}//endMainLoop
    #include <Tlc5940.h>

int ledCount = 96; //change  "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR

// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940  - tlc.set(dsply_state[x], 4000) ...or... tlc.set(dsply_state[x], 0)    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
  /  // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES. Needs help 
    for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b100000);    
    digitalWrite(M_S0, i & 0b010000);
    digitalWrite(S_S3, i & 0b001000);       
    digitalWrite(S_S2, i & 0b000100);
    digitalWrite(S_S1, i & 0b000010);
    digitalWrite(S_S0, i & 0b000001);
    
    delay(2);

    //need lotsa help here getting to each of the individual pixel readings 

    //get an individual reading from IR receiver/opAmp mux, store it in a variable?? //should this be INSIDE the for loop that pushes the readings into recv_state?

    int IRstate = analogRead(InputFromMux);

     //push individual readings into recv_state array. Maybe different code?
     
    for (int x=0; x<= ledCount; x++){
     
        //populate receiving array with a reading
        IRstate = recv_state[x];
    
        //populate display array for tlc5940 to push out
        recv_state[x] = dsply_state[x];

    } //endFirstForLoop

    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      
       for (int x = 0; x <= dsply_state.length; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
        //tlc5940 library - update clocks the chips
        Tlc.update();
         delay(10);
      
      } //end For Loop

}//endMainLoop
    #include <Tlc5940.h> //Arduino TLC5940 Library controls the individual LEDs - "Pixels"

int ledCount = 96; //change  "PIXEL" count in matrix...also number of IR sensor inputs

int thresh = 10; //value for usable distance reading from IR
int i;
int x;
// main structures to hold LED Pixel array on/off state, IR reciever readings
byte dsply_state[ledCount];    //pixel on-off grid, need for tlc5940  - tlc.set(dsply_state[x], 4000) ...or... tlc.set(dsply_state[x], 0)    
uint_16  recv_state[ledCount];           // IR Readings - FROM mux set-up  


// Master IR -mux sensor pins for Arduino Pro MINI
#define  M_S0 2
#define  M_S1 4
#define  M_S2 5
// Slave IR mux sensor pins
#define  S_S0 6
#define  S_S1 7
#define  S_S2 8
#define  S_S3 12


//  ANALOG PIN :
#define  InputFromMux A0

void setup() {
    //Serial.begin(9600);
    
    //tlc5940 library
    Tlc.init(0);
    
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(S_S3, OUTPUT);
    pinMode(InputFromMux, INPUT); 

}


void loop() {
  /  // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER and SLAVES. Needs help 
    for (int i = 0; i < ledCount; i++) {
  
    digitalWrite(M_S2, i & 0b1000000);
    digitalWrite(M_S1, i & 0b0100000);    
    digitalWrite(M_S0, i & 0b0010000);
    digitalWrite(S_S3, i & 0b0001000);       
    digitalWrite(S_S2, i & 0b0000100);
    digitalWrite(S_S1, i & 0b0000010);
    digitalWrite(S_S0, i & 0b0000001);
    
    delay(2);

    //need lotsa help here getting to each of the individual pixel readings

    //edited as per @Gerben. I think....

    //get an individual reading from IR receiver/opAmp mux, store it in a variable?? 
     int IRstate = analogRead(InputFromMux);

    //populate receiving array with a reading
     recv_state[i] = IRstate;
    
    //populate display array for tlc5940 to push out
     dsply_state[x] = recv_state[i];


    
      //run through display state array to check if the stored reading is greater than a threshold number
      //if yes, then turn on the "pixel". If not, set it to zero
      
       for (int x = 0; x <= dsply_state.length; x++)
          if (dsply_state[x] >= thresh ) {  
  
               Tlc.set(dsply_state[x], 4000);

             //or reading from mux is zero  
          } else if (dsply_state[x] < thresh) {
            
              Tlc.set(dsply_state[x], 0);
              }
              
            //tlc5940 library - update clocks the chips
        Tlc.update();
        delay(10);
      
      } //end For Loop

}//endMainLoop
deleted 4 characters in body
Source Link
Loading
Source Link
Loading