Good morning, Hope I have read enough of the FAQ to post a meaningful question.
I'm trying to turn a breadboard project into something thats actually useful and have a question about power and incorporating an on off switch.
I was plannign to use a battery bank type power supply (the ones you use for your phone etc) and connect it to my Uno via a USB cable as below (sorry for the appalling quality!!)
Thank you for your speedy response. So that would mean that i would have to open up the USB cable and add it to the red wire in that then.
I'm really sorry if i sound stupid but in all my other projects i've used a breadboard power supply which hasd a very obvious +5V wire. This is the first timeI'm attempting to make something portable, and that lack of wire +5V wire is confusing me!
I'm powering a few portable projects like You intend to do. I pull out one end of the USB cable to power them down... No extra stuff that might fail one day or the other...
Yes, but they cut off at different levels of current. Helpers once helped me to to arrange a timer pulling an output low. That output just draw som extra current. Works fine for one kind of packs but not for another. Trial and error....
void setup()
// put your setup code here, to run once:
{
//1Hz 90% dutycycle
pinMode(9, OUTPUT); // Set digital pin 9 (D9) to an output
TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(WGM11); // Enable the PWM output OC1A on digital pins 9 and invert output
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS12); // Set fast PWM and prescaler of 256 on timer 1
ICR1 = 62499; // Set the PWM frequency to 1Hz: 16MHz/(256 * 1Hz) - 1 = 62499
OCR1A = 6249; // Set the duty-cycle to 10%: 62499 / 10 = 6249
delay(10);//allow pwm timers to start
Just add a 270 ohm resistor between pin 9 and GND.
I appreciate the help offered so far but I’m at a very basic understanding stage .... I have a sensor , I can get sensible output from it , I can display that output on an lcd screen. I thought a power bank would be an easy way to power it.
This looks like a rabbit hole I’m not ready for yet
But USB chargers, if mains are available, don't have any surprising effects like that as far as I know. There are USB chargers running in cars, from 12 volt...
So I understand that my power bank may switch off if my sensor And display combo don’t draw enough current to tell it that something is connected ...and I understand the code and adding the resistor will force a certain amount of current to be drawn to trick the power bank into being constantly on
What I’m still hazy is where to put a switch . I have a power bank .... it has a USB cable going from it to my Arduino. This will be internal in my project box
On the opposite side of the power bank I have a USB port that will be flush with the outside so I can plug it in to recharge via a different cable
My understanding is that I will need to open the USB cable that’s inside... find the red +5v wire and cut it and add the switch into it