Switching bjt transistor with photodiode
I believe the polarity of your photodiode is incorrect. Typically, you want to use a photodiode in photoconductive mode with a BJT, which means that the photodiode should have an external reverse bias. Increased optical power causes a linear increase in reverse current through the device. This reverse current can then be amplified by the BJT transistor. Also note that increased photocurrent will cause the output voltage to decrease in this case, since the current and thus the voltage drop across the 100 Ohm resistor will increase. This is an easy fix if undesirable, another transistor or inverter can be used to reverse the polarity, or it can be reversed in software if you are going into a microcontroller.

EDIT: Your circuit is still not correct, try this instead. Note that R2 is not strictly required, but should be inserted to limit base current in case you have D1 backwards.







simulate this circuit &ndash; Schematic created using CircuitLab