when i press a single key from keyboard it gives me same output two time,
i need output only one time. (on pressing F1 one time it show F1 is pressed F1 is pressed <<<why 2 times????)
please suggest me code for solve my problem
// Initialize USB Controller
// Attach keyboard controller to USB
analogWrite(6,inten); //Display intensity
// Process USB tasks
x = keyboard.getOemKey();
if (x==58)lcd.print("F1 is ptressed");
if (x==59)lcd.print("F2 is ptressed");
if (x==60)lcd.print("F3 is ptressed");
And to if what @johnwasser suggested doesn't work, add try adding in a simple button denounce code before the keypressed() or getOemKey(). Just another thought to consider although I agree with John, I think it is reading the key depression and release.
thanks for quick response but in your case there was only two state of button (
low& high) while in my case state of button have many variable value more then 32 key each key have their unique value. problem is got this unique value to time in single pressing. (last state and current state same)
i hope u understand my problem i will wait for your valuable response.
Ok, I just want to make sure I understand you. You have 'x' amount of keys and each key has it's own set variable that shouldn't change. And you need to possibly, and I say "possibly" debounce each key press to get the output just the one time.
I have only denounced about 4 buttons at one time, I know you can do more, but you base each button from a digital pin input. And you included a so your trying to emulate the Keyboard, I feel so stupid now. Going back to what @johnwasser said about creating a keyPress() function. I'd suggest that instead of <KeyboardController.h> try using it should already be in your library. It supports the keyPress() function and others it should give you the one output that you are needing instead of the 2.
Does it work if you replace your loop() function with this:
int x = keyboard.getOemKey();
if (x == 58) lcd.print("F1 is ptressed");
if (x == 59) lcd.print("F2 is ptressed");
if (x == 60) lcd.print("F3 is ptressed");
// Process USB tasks
sir i'm got every key value on lcd after do as u suggest.i want to make a program to write on lcd using usb keyboard . but i'm facing some problem.
how to erase using' back space button ' how controller got the information about my cursor position.
my final objective is maintain the database of any organisation using due +lcd +usb key board.
can u suggest any program that would be helpful for me to achieve my gole