Hello, i have Leonardo board. And i have problem with it. I am searching for hours and can't solve it.
I want use Leonardo as native keyboard. Leonardo has native usb support. I have win10.
Here is my code... If i open serial monitor in Arduino IDE so it works. If close serial monitor and close IDE so still keyboard working. If re-plug Leonardo so again nothing work. I don't know what is bad or what i am doing bad. Can you help me please ? Arduino IDE latest version and all libraries are udpated.
#include <Arduino.h>
#include <Keyboard.h>
#include "Mux.h"
using namespace admux;
Mux mux(Pin(3, INPUT, PinType::Digital), Pinset(8, 9, 10, 11));
void setup() {
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
Keyboard.begin();
}
void loop() {
byte data;
for (byte i = 0; i <= 2; i++) {
if (i == 0 && mux.read(i) == 0) {
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press('r'); delay(150);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(150); //give your system time to catch up with these android-speed keyboard presses
Keyboard.println("mspaint");
}
if (i == 1 && mux.read(i) == 0) {
Keyboard.write('w');
}
if (i == 2 && mux.read(i) == 0) {
Keyboard.write('e');
}
}
delay(100);
}