I used this circuit as a reference to drive a relay from the digital output of an arduino. This circuit worked as expected.
Instead of controlling the 2N2222 with the arduino, I then tried to control it with the Panasonic EKMC1601112 motion sensor. The results were not good: I noticed that the output kept flickering on and off, even with no one in the room. I measured the output of the sensor and found that it was 5V when "on" and about 0.1V - 0.2V when "off".
I have several questions about this.
1) I'm assuming that 0.1V is enough to turn the 2N2222 on, which causes the flickering behavior. Does that sound right?
2) I know I can run the output of the motion sensor into the arduino (and I eventually will do that) but how can I adjust the existing circuit? Is the issue proper transistor biasing?
3) If I'm reading the AtMega328 data sheet correctly, when powered by 5V it recognizes a "low" signal up to 0.3V. So I should be fine if I use a digital input. What is normally done...is that "good enough" or would you do something to lower the voltage that appears at the AtMega input?
I'm assuming that the problem totally goes away if I connect the sensor to an analog input on the arduino. And again I may do that, but I really would like to understand the other issues involved.