I've looked at your schematic, and im not sure what you are doing with those transistors. Are you using them just to turn on and off the leds? is your pots there, to tune the current for the leds?
I use N-Mosfets, instead of transistors, they act more like a switch, transistors turn on more the more voltage/current their fed, but a fet can be turned on fully with a minimal of power. You can drive a FET directly from the chip, no resistor needed. heres what I would do, +5v to Pot Pin 1, Gnd to Pot Pin 3, Pot Pin 2 goes to LED +, LED- goes to FET Drain, FET Source goes to GND, FET Gate goes directly to PIC PIN. this allows to to turn on and off your LEDs with very little to no current/voltage loss on the FET, all FETs will be turned on the same ammount. FETs do not get as warm as regular transistors and can usually handle more current.
The only thing I see a problem with is how many LEDs in parallel you hook up to each POT, You can turn on a LED with 10-25ma, if you have 5 turned on and running at 125ma, that may cause a wattage problem for the POT. But this may not be a problem, It all depends on application and use.
#1 though, you shouldnt be sinking or driving LEDs to the PIC directly, its fine to do this on a breadboard for testing and such, however if your using many leds, its good to throw in a resistor. That notice on how much the chip can sink current wasnt placed there so you could sink current from leds, its a electrical rating for the chip for all outputs, when you hook up a button with a debounce circuit, the chip has to sink som of that current, each pin that has a high input with a resistor that the pic makes low, has to sink current. all these add up, if you start adding LEDs thats alot more it has to handle. It can make the chip work eratic, or fail, it may not happen today or tomarrow. best to just use the pins for data or drive another device to handle the voltage/current.
OH there is also another good reason to use FETs, you can use a seperate voltage source of a much higher voltage, you could drive 12volt headlights on a car using the right FET and they would behave just like the LED, or a Motor, or lots of things. Like I said a FET is like a 1-Direction Switch, either on or off.
Have fun, your project sounds interesting. I did the same type of project a few months back with very little code, not much different than yours. I just now read your thread so I didnt have a chance to post code before you got it working the way you wanted. good luck.![]()
Bookmarks