I have a portable project where I want to take care about batteries getting discharged.
Usually I just put a switch at the very beginning of my circuit that completely cuts off the electricity when switched off. The problem with this approach is that if you forget to switch it off your batteries will discharge.
So I was thinking about an approach that after some inactivity time cuts off the circuit (I want to completely cut off the electricity to minimize power consumption, so I'm not interested in sleeping modes or similar approaches).
So my approach consist in changing a switch for a regular push button that enables the circuit when pushed, and then one of the arduino pins is used to lock the transistor until a function times out and the pin gets to a low voltage (see image)
In the arduino code I can just test a simple program that keeps the circuit closed for 10 seconds and then switches it off.
setup() {
pinMode(3,OUTPUT);
digitalWrite(3,HIGH);
delay(10000);
digitalWrite(3,LOW);
}
loop() {
}
For the transistor part I'm not sure what to use. I was thinking about using an motor driver L298 (which should work and also accepts some load for other electronics that I might have in the project)
However this looks like something that should already exist (either in a shield or maybe integrated in some Arduino variant).
Does anybody have experience with such an approach or a suggestion on any standalone transistor that would also do the job?
Any help is appreciated :)