Hello everybody. My name is Andrea, I'm italian and this is my first post in this forum.
As you can read in the subject I am trying to switch a 12V lamp with a BC337 transistor.
I tryed to do what you can see in the attachment.
(instead of batteries there is a 12V transformer and instead of the resistor on the top there is the lamp)
What is the current (or wattage) rating of the lamp? The BC337 is rated for 800mA maximum, and you should leave a good safety margin. 12V @ 800mA is 9.6 Watts. If your lamp is more than a couple of Watts, you need a "bigger" transistor (probably with a heatsink) or a MOSFET with the appropriate current rating.
(instead of batteries there is a 12V transformer and instead of the resistor on the top there is the lamp)
Is that an AC transformer or a DC power supply? A single transistor won't work properly with AC.
In most places you use the name "TRANSISTOR" to designate Pin 8 but when you go to set the pin LOW you use the name "TRANS" instead. That is unlikely to be defined as 8 so I would expect your light to stay on.
Goodmorning to everybody and thanks for your answers.
The little 55W bulb I am using is taken from a car.
The transformer I am using is a AC-DC adaptor.
I wrote TRANS in the code I posted but I wanted to write TRANSISTOR. Sorry for my error that I have just corrected.
Maby (V/W)=(55/12)=4.58A are too mutch current for my transistor, as I can understand from what you are saying.
Can I connect more transistor in parallel to have less current on a single transistor?
You can see in the attachments my lamp and my adaptor.
I tried to switch on the lamp directly with the transformer and it works.
I tried with 6 parrallel transistors (without any resistances connected to collectors) and i burt one of them. I only saw a little light from the lamp.
Get a new (as in "not previously used") transistor.
I guess the resistor at the top of the drawing is there in place of the lamp?
Your picture doesn't show any connection between the breadboard common rail and the Arduino Ground.
Still, the cold resistance of such a lamp is going to be very low at start-up (resistance increases with temperature), perhaps enough to strain the transistor anyway.
Depending what your goal is, maybe you should consider a relay.
The resistor at the top of the drawing is the lamp.
I didn' connect the adaptor ground to the arduino ground but then I realised that i had to do it (even if i don't know why).
I also used a new transistor. Now the lamp "blinks" but when it should be off there is a lot of light and when it should be on there is more of light so the lamp is never off.
The cold resistance of such a lamp is going to be very low at start-up (resistance increases with temperature), perhaps enough to strain the transistor anyway.
Depending what your goal (simply On/Off?) is, maybe you should consider a relay.
My goal is learning how to manage higher voltages than 5V.
I also wanted to do something like a "fade-in / fade-out" but my light does not turn off completely.
What do you mean when you say "strain the transistor"?
randre:
What do you mean when you say "strain the transistor"?
Too much collector current!
Do you have an ohmmeter?
If so, measure the lamp's resistance (out of circuit). That's approximately the resistance the collector is seeing at start up.
Well then that appears to cinch it.
You need a better transistor.
You need a "logic-level" MOSFET.
Maybe, eventually, a few. (They can be paralleled for more current.)