Hey guys.. I originally posted this over on the Arduino forums, but since it is in C, I figured I should spread around my chances of finding an answer.

So, I am building a pretty big circuit that has 40 leds and 20 IR sensors. I have been prototyping using just 3 sensors with 6 leds. Right now, I can get the circuit to act how it is supposed to when an object passes in front of one of the sensors. When an object is detected, the Arduino talks to a shift register and sets the pin high this is associated the sensor. Each sensor is associated with 2 leds, one controlled by a standard inverter connected to a BJT that switches one of the leds. When nothing is in front of the sensor, the inverter causes the white led to illuminate, and when something is present, the shift register causes the inverter to go high (causing the BJT to switch) and the register switches another BJT to illuminate the other led. Before I confuse you much more, here is a drawing of what I am doing.

Here is a sketch of what I am talking about. Hopefully you can make out my handwriting.

I can see from the serial monitor that the sensors are detecting movement at the same time, but only one light will change at a time.

Here is the code.

Code ( (Unknown Language)):

int sV01 = 0; //Sensor 1 Analog Value

int sV02 = 0; //Sensor 2 Analog Value

int sV03 = 0; //Sensor 3 Analog Value

int bitToSet;

//Pin connected to latch pin (ST_CP) of 74HC595

const int latchPin = 8;

//Pin connected to clock pin (SH_CP) of 74HC595

const int clockPin = 12;

//Pin connected to Data in (DS) of 74HC595

const int dataPin = 11;

//Pin for Sensor01

const int s01 = 1;

//Pin for Sensor02

const int s02 = 2;

//Pin for Sensor03

const int s03 = 3;

//Pin for Master Resest (Active Low)

const int mRPin = 10;

int sValue;

void setup()

{

Serial.begin(9600); //Begin serial communcation );

//Set pins to output because they are addressed in the main loop

pinMode(latchPin, OUTPUT);

pinMode(dataPin, OUTPUT);

pinMode(clockPin, OUTPUT);

pinMode(mRPin, OUTPUT);

Serial.begin(9600);

Serial.println("reset");

}

void loop()

{

digitalWrite(mRPin, HIGH);

for(int i = 0; i < 3; i++)

{

Serial.print("__");

Serial.print(analogRead(i)); //Write the value of the photoresistor to the serial monitor.

Thank you for moving the post where it might get a little more attention. I am not really sure what you are asking about the transistors. One gate input is being controlled by an inverter and the other is directly controlled by the shift register. So, when the register pin is low, the gate inline with the inverter will switch the led on. When the pin is high, the other led turns on.

Ohhh,. I just looked and I used a PNP symbol instead of the NPN type transistor. It is supposed to be a NPN type, 2n4401 BJT.

Thank you Bertus. I already had a resistor on the base of the transistor directly connected to the shift register. Sgt Wookie really helped me out understanding how to calculate the required base resistor.

I will be adding in that second resistor as soon as possible also. But, do you see why my code is not working when trying to turn on two pins at the same time using this bit of code?