Hi everyone! I have an Arduino Pro Micro that I was planning to use as a keyboard that automatically enters the passcode to an Android phone. I want to just plug the Arduino and not have to wake the phone first and swipe up to get to the on-screen keypad that appears to enter the passcode. So I tried it first with a real keyboard to see if there is a key that wakes the phone and opens the on-screen keypad, and, to my surprise, it doesn't matter which key I press they all do what I want if I press any key the phone wakes up, then if I press any other key the keypad appears.
Now the problem Is that the Arduino wakes the phone but is unable to get to the on-screen keypad, this is my code
#include "Keyboard.h"
void setup() {
// put your setup code here, to run once:
delay(10000);
Keyboard.begin();
Keyboard.println(0); //<------Works, wakes the phone
delay(2000);
Keyboard.println(0); //<------Doesn't work, doesn't open the keypad
Keyboard.end();
}
void loop() {
// put your main code here, to run repeatedly:
}
Maybe Im missing something, I tried all the functions Keyboard.print(), Keyboard.println(), Keyboard.write() and Keyboard.press(), Keyboard.release()
I hope someone knows why the Arduino is not able to open de keypad, I tried with all this and various numbers and letters.
OK... How do you enter a passcode on a USB keyboard? Let's say your passcode is "1234". Do you type '1', '2', '3', '4', 'Enter'? You should be able to do the same with the Arduino with Keyboard.println("1234");
Sometimes games get upset at how quickly the Arduino sends a 'release' after sending a 'press'. Maybe the android passcode is similar. You can work around that by doing the two operations separately with a slight delay:
Keyboard.press('1');
delay(10);
Keyboard.release('1');
Keyboard.press('2');
delay(10);
Keyboard.release('2');
Keyboard.press('3');
delay(10);
Keyboard.release('3');
Keyboard.press('4');
delay(10);
Keyboard.release('4');
Keyboard.press('\n'); // Enter
delay(10);
Keyboard.release('\n'); // Enter
I can't see why Serial.write wouldn't be sending along the characters, nor why the device would get the first such character and react properly but ignore, or react differently, to receiving the second.
I did exactly what I described, I'm also perplexed. I guess It has to be something to do with what is being sent by the Arduino and what a real keyboard sends.
#include "Keyboard.h"
void setup() {
// put your setup code here, to run once:
delay(10000);
Keyboard.begin();
Keyboard.press('1'); //<--- Works wakes the phone
delay(500);
Keyboard.release('1');
delay(1500);
Keyboard.press('2');
delay(500);
Keyboard.release('2');//<---Doesn't work, doesn't show keypad
Keyboard.end();
}
void loop() {
// put your main code here, to run repeatedly:
}