i have successfully interfaced usb keyboard and printing value on serial monitor.
in my program" enter_name() " this function print value of pres key but when i same key two time it print only one time. what improvement should i done in this function to solve my problem.
#include <KeyboardController.h>
// Initialize USB Controller
USBHost usb;
// Attach keyboard controller to USB
KeyboardController keyboard(usb);
char key,key1;
void setup()
{i=0;
Serial.begin(115200);
Serial.println("Program started");
delay(200);
}
void enter_name(){
usb.Task();// Process USB tasks
key=keyboard.getKey();
//////////////////// I lock it because keyboard.getKey(); give same value two time////////////
if(key1!=key)
{Serial.println(key); key1=key;}
return;
}
void loop()
{
enter_name();
}
To get rid of your issue with keys showing up twice, you added code so you can never have the same key twice in a row.
To fix it, add a void keyPressed() function which will get called each time a key is pressed. In that function you call keyboard.getKey() to get the key value.
hello mohitnama4001,
I am looking to use a usb keyboard with an arduino board due or other.
Could you post the information about the hardware you use to connect the USB keyboard to your arduino?
Good evening,
I just received a DUE card, I saw that there were two micro usb ports, one of which would connect a USB keyboard (Native USB). So I’m going to buy a keyboard and a micro usb adapter, I hope using the "KeyboardController library. h" I will be able to use this keyboard as input device with the DUE card.
So I’m sorry I asked a silly question...