What you are getting is correct, you have it configured as an emitter follower circuit. You need to ground the emitter. Put a resistor a few hundred to 1K Ohms between the gpio and the base of the transistor. The collector becomes your output and goes to the - side of your load while the load + goes to the + of the power supply. If it is an inductive load add a diode with the cathode on the positive and the anode on the collector. Let us know how this works. Knowing your load would make this much easier to answer correctly.
@gilshultz - yes, it's an emitter follower - project is quit simple.
arduino reads the LDR on A1, and triggers 12v to the ilumination of my car's navigation headunit, so it dims according light conditions, not when headligths are triggered.
As all grounds are common, i just need to feed this connection with 12V, and the most simple way, imho, is to have a transistor feeding it, as the power drain is very low.
But seams tha NPN is not a good idea, due the tension drop.
connecting the illumination connection to the collector side, will make it llways active, as collector is feeded by 12V.
No.
The load needs to be between the collector and the supply.
The GPIO needs to be one capable of PWM and you need to write to it using an analogWrite function call.
As you have it when you turn on the transistor you will short out your 12V supply and get a big bang, or things will melt.
If you need to switch the high side and leave the load connected to ground, then a PNP is what you would use. But you can't drive a PNP directly from a GPIO if it's switching 12V. You would need to have the GPIO drive an NPN, which in turn drives the PNP. You would need base resistors for both transistors.
Probably "very low" compared to a headlight, but likely in the order of an Amp. A 10k base resistor was never going to "cut it" anyway, nor I suspect was a 2N2222.
You need a P-FET with source to 12 V and drain to the panel lights. The gate then needs to be pulled down with an N-FET or NPN transistor.
This device would do the job nicely as it includes both FETs.
It will provided your load doesn't overload Q2.
But you may add a resistor between basis (base?) of Q2 and +12V to have this pin not floating when Q1 is off. And a diode in series with R1 may help also to shift the "off" level to 1.4V (instead of 0.7V in your design) to increase robustness in case of noise on your GND.
"But you may add a resistor between basis (base?) of Q2 and +12V to have this pin not floating when Q1 is off. And a diode in series with R1 may help also to shift the "off" level to 1.4V (instead of 0.7V in your design) to increase robustness in case of noise on your GND."
Pretty uncritical. Voltages are all low, current as well. So even a small 1N4148 would do the job - it is just to add 0.7V voltage (drop) to properly separate high-level from low-level output of your controller. So take what you have.
I am waiting for you to specify just what current that illumination draws, which you need to have measured.
The 2N3906 is almost certainly completely unsuitable, while the BC327 at 800 mA rating may be usable if the current is no more than 500 mA and you drive it with 25 mA with a value of R3 as 470 ohms. You don't need a pullup on Q2 using BJTs in this application.
If the current is more than 600 mA, then I repeat that this device would be vastly more suitable using ShermanP's circuit.
facto: Pioneer and other head units have a lead for hooking the dash illumination for dimming when lights (head, tail and dash lights) are on. It's just a sensor, like the remote switch of car amplifiers.
Yes, by setup you can define by time (dim from hh:mm to hh:mm), auto (car lights) and manual.
neither of those fits my desire.
what i want: have the dash head unit dim according light conditions, independent of the car lights on or off - so simple as that.