i have a simple mouse mover program that works fine after an upload.
i can then exit the IDE and it works fine.
but if i just plug it in without the ide, the leonardo doesnt do anything.
do i need to set up a port or something?
#include "Keyboard.h"
#include "Mouse.h"
#include "string.h"
int buttonstate;
int buttonPin=8;
String btn2str = "start";
char cc;
int len;
int onetime=0;
int jj=0;
void setup() { // initialize the buttons' inputs
// initialize mouse control:
delay(3000);
Mouse.begin();
Keyboard.begin();
pinMode(LED_BUILTIN, OUTPUT);
pinMode(buttonPin, INPUT);
delay(200);
flash5times(1000);
flash5times(100);
Keyboard.println(btn2str);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
buttonstate = digitalRead(buttonPin);
delay(100);
// move mouse every 5 min
if (jj>50) {
flash5times(300);
Mouse.move(100, 100);
delay(50);
Mouse.move(-99,-99);
delay(50);
Mouse.move(100, 100);
delay(50);
Mouse.move(-101,-101);
jj=0;
}
delay(500);
jj++;
}
thats it, it is just a simulated mouse move even X minutes to keep my screen from locking every time i walk away.
the security lockout is set to 5 minutes on my laptop so anytime I get up, i have to login again (even tho i work from home by myself)
the buttons previously actually typed my passwords but i have stripped that out for now.
i am brushing off an old program from 6 years ago which worked great but maybe there is something about the new board givng me problems.
i tried this code and grounded A0. i still have the same issue.
i upload from the IDE, it runs fine. the mouse moves.
but if i dont use the IDE and just plug in or restart the leonardo, it does nothing.
just the blue light, no yellow and no mouse moves.
I think you will find that keyboard.h waits for the serial connection to be available. So in fact you are testing that that function does, in fact, work that way.