Usb keybord+arduino due

Hello ,

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()


  Serial.println("Program started");


void enter_name(){
 usb.Task();// Process USB tasks
//////////////////// I lock it because keyboard.getKey(); give same value two time////////////   
 {Serial.println(key); key1=key;} 

void loop()


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?

Thank you in advance for your help.

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...

Good evening.

Finally it is very easy to use a USB keyboard with an arduino board due.

#include <KeyboardController.h>
char   key;
// Initialise l'USB Controlleur
USBHost usb;

KeyboardController keyboard(usb);

void setup(){

void loop(){

void keyPressed() {
if (keyboard.getOemKey()==42) key ='E';
if (keyboard.getOemKey()==76) key ='C';


case 112 : key ='P'; lcd.print(key); break;
case 80 : key ='P'; lcd.print(key); break;
case 19 : key ='='; lcd.print(key); break;
case 99 : key ='C';  break;
case 67 : key ='C'; break;
case 101 : key ='E';break;
case 69 : key ='E'; break;
case 114 : key ='R'; break;
case 82 : key ='R'; break;
case 47 : key ='/'; lcd.print(key); break;
case 45 : key ='-'; lcd.print(key); break;
case 43 : key ='+'; lcd.print(key); break;
case 42 : key ='*'; lcd.print(key); break;
case 46 : key ='.'; lcd.print(key); break;
case 48 : key ='0'; lcd.print(key); break;
case 49 : key ='1';lcd.print(key); break;
case 50 : key ='2';lcd.print(key); break;
case 51 : key ='3';lcd.print(key); break;
case 52 : key ='4';lcd.print(key); break;
case 53 : key ='5';lcd.print(key); break;
case 54 : key ='6';lcd.print(key); break;
case 55 : key ='7';lcd.print(key); break;
case 56 : key ='8';lcd.print(key); break;
case 57 : key ='9';lcd.print(key); break;


good day


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.