Go Down

Topic: 4x3 membrane keypad as input [help please] (Read 1 time) previous topic - next topic

PaulS

Quote
and the serial monitor shows my keystrokes
No, it does not. It shows some text sent by the Arduino. That is NOT the same as a keystroke.

The Serial pot is useful to get the code to the point where it can properly read from the keypad. Since you have that working, you now need to stop using Serial, so that the Keyboard class can talk to the PC, in a manner that does not use Serial.

Instead of using Serial.print(key), you will use Keyboard.press(key), a small delay, and Keyboard.release(key);. Look at thhe Keyboard examples, as I have said repeatedly.
The art of getting good answers lies in asking good questions.

wodm

Thank you again
i shall give this a quick try in a minute then sadly, its of to work i go.
I will report back and let you know how much of a start you have been

PaulS

Quote
I can't read the music format.
That's the Disney theme song. " I owe, I  owe, so off to work i go...".
The art of getting good answers lies in asking good questions.

wodm

i think i owe you a coffee :)

123456789*0£

all typed with the number pad. only problem is the £ is actually a # on the pad but that easily fixed (keyboard setting maybe?)

Anyway, i removed  Serial.print(key) and replaced it with
Code: [Select]
Keyboard.press(key);
    delay; 500,
    Keyboard.release(key)


Thank you for your help (and patience)

PaulS

Quote
Anyway, i removed  Serial.print(key) and replaced it with
I hope you mean "something like", because there are problems with that snippet.

The art of getting good answers lies in asking good questions.

wodm

I hope you mean "something like", because there are problems with that snippet.


what have i done wrong?

PaulS

The snippet should be:
Code: [Select]
    Keyboard.press(key);
    delay(500);
    Keyboard.release(key);


The last line was missing a ;. The middle one was not calling delay(). The 500, bit was just weird.
The art of getting good answers lies in asking good questions.

PaulS

By the way, holding the key pressed for half a second might be way too long. I'd be using 10, not 500, as the key down time.
The art of getting good answers lies in asking good questions.

wodm

I see, learning all the time. In work now but will alter my sketch once home.
It's starting to make sense now.

wodm

home from work, tested and working.
Just tried in game to assign controls and it works without issue.

Thanks for your help and thank you for not just giving me the answer either ;)

Go Up