I'm looking for two answer here.
Is it possible to power a Leonardo to be always on, separate from the power from the USB host - I've tried with a full size Leonardo and a power adapter but for some reason the code didn't run when I did that. I've bought a battery shield too which will be arriving soon.
I want it be power-able via a switch with batteries so that I do a few things. For a start avoid it's boot up time and have it pressing a key as soon as the booted computer sees it (I'm running it as a keyboard/mouse via USB-HID) and also at one point I have the computer send serial data to have the Arduino run a different part of it's code...at this point the host computer reboots. Obviously that means the Arduino will see it's USB host disappear then come back online, will that automatically reset it and thus start it from the beginning again, or can I set it so that with always on power it will carry on doing what it is, irregardless of it's connecting to the host?
Do I need to change code, or libraries to achieve any of this?
With the theory intact answered, here is some of my actual code, i've stripped most of it out as it's just a bunch of keyboard presses
#include <Keyboard.h>
#include <Mouse.h>
char returnKey = KEY_RETURN;
char tabKey = KEY_TAB;
void setup() {
Keyboard.begin();
Mouse.begin();
// delay(60000); //Deploy Delay
delay(3000); //Testing Delay
// Keyboard commands
Keyboard.write(returnKey);
delay(14000);
// Welcome Screen
Mouse.click(MOUSE_LEFT);
delay(100);
}
void loop() {
}