I have two marineland led aquarium lights that use a 12v ---- 1000mA wall wart for power and uses a coaxial plug on the lamp. Then the power is sent to a 3 way rocker switch position "II" lights all 78 leds (72 white and 6 blue), position "I" is just the 6 blue leds, and of course "o" is off.
i would like to replace the rocker switch and use my uno to control the lamp with a timer that can switch between the modes of the rocker switch. I have very limited knowledge with the uno or electrical circuitry, from what i've read so far it seems that i could use a npn transistor to do what i'm trying to achieve so i picked up 4 tip120 and some 1k and 2k resistors. With my limited knowledge i'm worried about trying to hook it up and damaging my uno or the lamp.
Could someone help me with piecing it together so i don't damage anything.
Here are a couple of pictures showing what i'm working with.
looks like the above pic is small, its like this but with two of the boards in each lamp.
You should get "pinboard" on 0.1 inch pitch to poke around.
On many arduino versions (I tend to use nano 328) pins labelled D6, D7, D8, D9 are a sensible choice.
Have a look in examples for some digital output.
You'll want it to do something once (in the "setup" part of your code which establishes pinMode(6,OUTPUT) and sets the digital output of pin 6 to "0" == "LOW".
You won't break anything running a 2kOhm resistor from pin 6 to the base of an npn transistor whose grounded 'e' goes to the GND used by the arduino.
First try that with a single LED and 1kOhm from the 'c' to 5V so that you can see it blink as controlled by your program.
If you don't have a $ for a fivepack of bog standard LED's then scavenge a red from scrap and the fatter embedded metal thing must always point toward ground (-).
The other way of testing is to use 12V and your aquarium light above your npn transistor. A string of LED's does nothing until at least 2/3 of its rated voltage is supplied and giving it 200mA from one transistor will go to about 8 or 9 Volts "used up" from the 12 ish volt supply. Being pessimistic call that 14V and "up to" 6 Volts unaccounted for get dissipated at the transistor. That is, 1.2 Watts could be dissipated by that transistor in its "half-ON" state, and I have not looked at the datasheet to see whether it is big enough to handle quite of lot of heat from that. That is why I'd suggest
i) bigger R from digital output pin
ii) try things with smaller single LED'S until you get the hang of it
iii) do not use your 12V 1A rated supply until you are sure that you can cleanly switch that much.
Once you have that working, you probably want to improve your knowledge of timing functions and have a look at the "blink without delay()" example. You will also want to beware of the old computer problem that big numbers are not always acceptable to a microcontroller which prefers 16 bit integers.
I've not checked your transistor for ability to comfortably supply 1000 mA so expect to buy more. A ten pack of 1/2 Amp rated npn's does not cost much. Expecting 4V/2kOhm = 2mA into the base, most transistors won't pass more than 2mA x gain; about 200mA for a type which I use.
Four 2kOhm from a single digital output is starting to get closeish to the "that will burn your arduino" limit, so I'd prefer to see a bigger R from pin D6 to an npn which can drive the bases of quite a few transistors through 1kOhm each from 5V. That is, a tiny current from a digital output of your microcontroller to one base of one transistor permits it to pass a few mA to a few bases of transistors below it, and those ones cleanly switch on the 1000mA. Above those main transistors you can go to your aquarium lights with their separate +12V supply.
ad2049q:
You should get "pinboard" on 0.1 inch pitch to poke around. - by "pinboard" are you talking about a breadboard? if so i have one that came with the starter kit, if not i'm lost and could you expand on it.
On many arduino versions (I tend to use nano 328) pins labelled D6, D7, D8, D9 are a sensible choice.
Have a look in examples for some digital output.
You'll want it to do something once (in the "setup" part of your code which establishes pinMode(6,OUTPUT) and sets the digital output of pin 6 to "0" == "LOW".
You won't break anything running a 2kOhm resistor from pin 6 to the base of an npn transistor whose grounded 'e' goes to the GND used by the arduino.
First try that with a single LED and 1kOhm from the 'c' to 5V so that you can see it blink as controlled by your program.
If you don't have a $ for a fivepack of bog standard LED's then scavenge a red from scrap and the fatter embedded metal thing must always point toward ground (-).
The other way of testing is to use 12V and your aquarium light above your npn transistor. A string of LED's does nothing until at least 2/3 of its rated voltage is supplied and giving it 200mA from one transistor will go to about 8 or 9 Volts "used up" from the 12 ish volt supply. Being pessimistic call that 14V and "up to" 6 Volts unaccounted for get dissipated at the transistor. That is, 1.2 Watts could be dissipated by that transistor in its "half-ON" state, and I have not looked at the datasheet to see whether it is big enough to handle quite of lot of heat from that. That is why I'd suggest
i) bigger R from digital output pin -what size resistor would be recommended, i picked up a multipack while i was out earlier.
ii) try things with smaller single LED'S until you get the hang of it
iii) do not use your 12V 1A rated supply until you are sure that you can cleanly switch that much.
Once you have that working, you probably want to improve your knowledge of timing functions and have a look at the "blink without delay()" example. You will also want to beware of the old computer problem that big numbers are not always acceptable to a microcontroller which prefers 16 bit integers.
I've not checked your transistor for ability to comfortably supply 1000 mA so expect to buy more. A ten pack of 1/2 Amp rated npn's does not cost much. Expecting 4V/2kOhm = 2mA into the base, most transistors won't pass more than 2mA x gain; about 200mA for a type which I use.
Four 2kOhm from a single digital output is starting to get closeish to the "that will burn your arduino" limit, so I'd prefer to see a bigger R from pin D6 to an npn which can drive the bases of quite a few transistors through 1kOhm each from 5V. That is, a tiny current from a digital output of your microcontroller to one base of one transistor permits it to pass a few mA to a few bases of transistors below it, and those ones cleanly switch on the 1000mA. Above those main transistors you can go to your aquarium lights with their separate +12V supply.
I've used this circuit to run the lights without any problem.
I've seen other schematics that change the resistor to this, it doesn't seem correct to me but.... still learning.
The data sheet for the tip120 puts hfe - DC current gain at 1000, since i don't understand that and going off of what others have posted it allows for 5A. Would that be correct?
Also looking at the data sheet myself it says the Absolute Maximum Ratings
Ic collector current(dc) 5 A
Icp collector current (pulse) 8 A
ad2049q:
I've not checked your transistor for ability to comfortably supply 1000 mA so expect to buy more. A ten pack of 1/2 Amp rated npn's does not cost much. Expecting 4V/2kOhm = 2mA into the base, most transistors won't pass more than 2mA x gain; about 200mA for a type which I use.
Four 2kOhm from a single digital output is starting to get closeish to the "that will burn your arduino" limit, so I'd prefer to see a bigger R from pin D6 to an npn which can drive the bases of quite a few transistors through 1kOhm each from 5V. That is, a tiny current from a digital output of your microcontroller to one base of one transistor permits it to pass a few mA to a few bases of transistors below it, and those ones cleanly switch on the 1000mA. Above those main transistors you can go to your aquarium lights with their separate +12V supply.
This confusing story implies that you want to use the transistor in it's linear region (2mA x gain).
Bad idea for switching (voltdrop/heat).
Switching (saturation) needs ~1:20 base current for small transistors to ~1:10 for the bigger ones.
100mA base current would be needed to switch 1Amp. One pin can't supply that.
Four 2k resistors into four bases is ~9.15mA. Well under the limit of a pin. Ten (200ohm) would be still ok.
A TIP120 (darlington) is also a bad idea. 1:250 base current is needed, so easier on the Arduino pin.
But a darlington has a high-ish saturation voltage. It could get hot, and the LEDs will likely be dimmer.
Both Fritzing diagrams are wrong.
Collector and emitter are swapped (ground goes to the pin on the right, LED to the middle pin).
The resistor is correct in the first diagram (between pin and base).
Wawa:
This confusing story implies that you want to use the transistor in it's linear region (2mA x gain).
Bad idea for switching (voltdrop/heat).
Switching (saturation) needs ~1:20 base current for small transistors to ~1:10 for the bigger ones.
100mA base current would be needed to switch 1Amp. One pin can't supply that.
Four 2k resistors into four bases is ~9.15mA. Well under the limit of a pin. Ten (200ohm) would be still ok.
A TIP120 (darlington) is also a bad idea. 1:250 base current is needed, so easier on the Arduino pin.
But a darlington has a high-ish saturation voltage. It could get hot, and the LEDs will likely be dimmer.
Both Fritzing diagrams are wrong. - Thanks i had it wired correctly on the breadboard but did it wrong in fritz.
Collector and emitter are swapped (ground goes to the pin on the right, LED to the middle pin).
The resistor is correct in the first diagram (between pin and base).
The best option is logic level mosfets. - Thanks this makes so much sense.
Leo..
This page explains mosfets switching in great detail.
Diagram#1 can be used to switch the ground lead of a motor/solenoid/LED/etc ("load" = LED).
The kickback diode is needed for inductive loads, but not for LEDs.
Leo..
Quick and dirty explanation.
The gate of a fet has an extreme high impedance, so no current flows in/out of the gate when the fet is "on" or "off".
It would not make a difference is there was no resistor (short) or a 1,000,000 ohm resistor.
But a fet also has gate capacitance. About 1-10nF for an average power fet.
That gate capacitor has to be charged/discharged when the Arduino pin switches the fet on/off.
The gate resistor is there to limit Arduino pin current to a safe value during that charging/discharging.
You want it to be done quickly to reduce switching losses, so a low-ish value.
There is also a (10k) resistor from gate to ground, or better, from pin to ground.
It's there to keep the gate firmly grounded untill the Arduino has booted, and has full control over the pin.
Leo..
So my thinking was going back to the tip120 that would pull to many mA to the gate. The mosfet using logic V only needs a pulldown or pullup resistor depending on which type so the gate will respond quickly.
DougStanley:
So my thinking was going back to the tip120 that would pull to many mA to the gate.
A TIP120 is a darlington transistor, not a mosfet.
It has a base that is current driven, not a gate that is voltage driven.
A darlington is basically two stacked transistors in one package to increase gain.
They need very little base current to saturate. A 1:250 ratio is common.
1mA base current for every 250mA of collector current, so 20mA from the Arduino is basically good for 5Amp collector current.
Because of the two stacked transistors, saturation voltage (what remains over a closed "switch") is high.
About 1.5volt@1Amp and about 2.25volt@5Amp collector current.
That creates 1.5volt * 1Amp = 1.5watt of heat/loss in the transistor. Too hot without heatsink.
The other enemy with a TIP120 is that saturation volt drop.
The light probably uses three ~3.3volt LEDs in series (common).
That drops ~9.9volt from your 12volt supply.
~2.1volt left for the transistor switch AND the current limiting resistors.
1.5volt lost across the transistor means less across the current limiting resistors.
Dimmer LEDs, unless you compensate for that loss with a higher (13.5volt) supply.
DougStanley:
The mosfet using logic V only needs a pulldown or pullup resistor depending on which type so the gate will respond quickly.
Is this correct?
The Arduino pin does the "pushing" and the "pulling" (sourcing and sinking).
The gate resistor limits the intensity of that to a safe value for the Arduino pin.
Leo..