I am currently trying to fade the music coming through the speakers in a car using an Arduino. I know that the Arduino works on 3.3 volts, and the car works on a 12 volt system, but I cannot find a way of controlling the 12 volt signal in an analog manner.
My initial thought was to use a transistor (NPN or PNP?) to control the 12 volt signal with a 3.3 volt PWM signal from the Arduino. I don't know whether this would work as I do not know how to wire it correctly.
Any help on this matter would be much appreciated.
My initial thought was to use a transistor (NPN or PNP?) to control the 12 volt signal with a 3.3 volt PWM signal from the Arduino.
What's this "12V signal"?
We need to know more about your stereo... Are you saying your stereo has a special input for "fading" the volume? Are you sure it's analog?
Some car stereos have steering wheel controls, and you could tap-into that. I don't know exactly how those work, but I assume it's just a switch so you shouldn't need PWM or analog. A relay is the "safest" way to automate a switch if you don't know anything about the signal you are switching.
I know that the Arduino works on 3.3 volts
The standard Arduino is actually 5V (the Arduino Due is 3.3v), but you are right that you can't directly interface with 12V.
As something of a car sound system buff the subject grabbed my attention.
The car's power system is nominally 12V. I say nominally because in reality you're going to get anything from about 8V up to about 16V, with occasional spikes due to load dumps of hundreds of volts. Car's electrical systems are nasty things, and you should never interface electronics to them without heavy protection.
There are many many examples of reliable power supplies out there for automotive applications, my favorite is basically a zener diode, a few capacitors and an LM317 voltage regulator to get something like 9VDC (Though 5 or 3.3 is also easy enough with this) so power for the Arduino is an easy enough matter.
Speakers on the other hand is something else. If you want to deal with signal processing, you're going to need to work with a pre-amplified music source. Easy enough if you have a stereo with pre-amplified outputs and are using an external amplifier. Harder if you're using an amplified deck.
The reason is that 12V simply isn't a lot to work with when your speakers are at least a nominal resistance of 4 ohm. Without some sort of SMPS, you're limited to about 30W maximum, which comes out to about 12W/channel. Not exactly great. So car stereo systems use a SMPS to ramp up the available DC voltage, and instead of a signal/ground pair, they run the amplifiers in bridge-tied load mode with a positive and negative signal. This means that you don't have a voltage relative to ground on the speaker wires, you have a voltage relative to the other wire. This can be tricky to process, but not impossible.
You can buy simple converters in car stereo shops which take speaker level inputs and put out line level. Rather than re-invent the wheel, I would suggest starting with that.
Probably the whole thing would be easier to put some servos under the Arduino's control and have them turn the stereo knobs for you.