Hi all,
this is my first post on the arduino forums. I've been coming here for help for years now and can usually find a topic that helps me solve my problems - so a big thank you to the community in general for creating such a useful resource.
I've had a search through the forums, and on this occasion I can find some very similar posts, but seemingly none that directly relate. I am just a beginner though, so this could be due to my own lack of knowledge about transistors and the ATMega328 chip.
I'm working on some custom bike lights for a friend. I'd like to use one switch: to turn the ATMega328 on; cycle through different modes; and then switch off again. When the circuit is off it should use no power.
I'm using an NPN transistor to control the path to ground for the ATMega328 and a ULN2803 that drives the LEDs. A DPST switch both acts as a standard button http://arduino.cc/en/tutorial/button#.UyWxDYVQjs4, and also powers the base of the transistor. The idea is that when pressed, the ATMega328 can switch on, and send a self-sustaining current from a digital pin to the same transistor. The button can then be used to switch modes, with the final mode switching the Arduino off.
The problem I'm seeing is even when the ATmega328 should be completely off, the transistor is still powering the ATMega. I've included a schematic below.
Am I using the transistor correctly? Is this approach even possible? If not, what approach would you recommend?
If you're also in a position to recommend a charging circuit (schematic or pre-made) and battery, please do, as I'll (hopefully) be needing that soon too.
Need to know the specs (hfe (gain)) of the transistor. I would use an NPN but PNP is ok if the base current is correct. The problem I see is that a PNP turns on when the base is grounded (through current limiting resistor) but you have no pullup (10k) resistor to keep it off when it is not on. Upload the transistor datasheet.
I need a schematic (or connection list) that shows how you connected the NPN transistor pins. Your pnp schematic won't work because pnp/npn connections are opposite. I still don't see any base resistor for the npn for the ON state. You need one for ON
and one for OFF because the connections are switched. Please supply an accurate schematic.
So what about the other half of the schematic ?
What connects to "Power On" and "Button Input" ? Isn't that missing ? How do I know where those lines go ?
Add those connections and then it should be complete and I can answer your question.
Thanks for your patience. The above is the schematic showing all connections to the ATMega328. The ATMega328 is running code that will set pin 18 HIGH when it starts up, and LOW when the program is finished. Pin 16 is set as a digital input for the button (which is DPST momentary ON), and pins 3,4,5,6,11,12,13,14 are set as digital outputs.
All the other connections (capacitors, clock, resistor pin 0 to ground) are from following the tutorial here: http://www.gammon.com.au/forum/?id=11637
'm using an NPN transistor to control the path to ground for the ATMega328 and a ULN2803 that drives the LEDs. A DPST switch both acts as a standard button http://arduino.cc/en/tutorial/button#.UyWxDYVQjs4, and also powers the base of the transistor. The idea is that when pressed, the ATMega328 can switch on, and send a self-sustaining current from a digital pin to the same transistor. The button can then be used to switch modes, with the final mode switching the Arduino off.
Have you tried connecting the base of the transistor to ground to turn it off and measure the current. It is safe to do this because the base can only be damaged by positive voltage and grounding the base guarantees no base current.
This has to work before you go any further. The schematic looks ok but until I know the results of this test I don't want to say any more. You should know how to test transistor using diode scale on a DMM. please verify it is not shorted, which would keep the ATmega on no matter what you do. Once you can tell me you can turn it on and off manually by disconnect your circuit from the base and connecting it to ground or +5V with a resistor then we can proceed.