4x3 membrane keypad as input [help please]

Hi All

I have searched but cant find the answer so thought i would ask.

I am new to arduino and coding so would love some help and / or advice regarding membrane button pads.

I have a 4x3 pad and have it connected to my arduino micro (have also had it on my uno and teensy 3.1)
I can see my button press registering in the serial monitor but cant figure out how to make them register in say.. notepad for example.

Is it possible or am i missing a setting in the IDE? i have the kepad library etc but i am lost now.

Ultimately, i want to have simple control over a couple of in game commands and would rather use the membrane than build a button panel.

Thanks in advance for any help.

/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>

const byte ROWS = 3; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'3','6','9','#'},
  {'2','5','8','0'},
  {'1','4','7','*'}
};
byte rowPins[ROWS] = {6, 7, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {12, 11, 10, 9}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
}
  
void loop(){
  char key = keypad.getKey();
  
  if (key){
    Serial.println(key);
  }
}

Is it possible

Not unless you can figure out how to install Notepad on the Arduino.

ok, joking aside, (i assume you were making a joke) i want to press a button and it read as a keystroke on my pc. It doesnt have to be notepad.
The button press is registering in serial monitor because i can see it but is there a way for it to be read as a keystroke on the pc itself?

As i said, i am a complete newbie to this and was after some help.

Which Arduino do you have? Only the discontinued Leonardo and the Micro have the hardware to send keystrokes. The others can not.

PaulS:
Which Arduino do you have? Only the discontinued Leonardo and the Micro have the hardware to send keystrokes. The others can not.

I have 2 officail arduino. 1 uno r3 and 1 micro. i also have a teensy 3.1

The teensy or the Micro will work. So, what is the problem?

PaulS:
The teensy or the Micro will work. So, what is the problem?

im not sure, i have posted the code i am using. when i open the serial monitor, it works but i cant figure out why it does nothing in the pc itself. I may have an incorrect setting orsomething but i just dont know.

Am i right in thinking that if i am in any text editor, then the button press should show as a number in the editor?

board is set to micro
programmer is USBtinyISP

but i cant figure out why it does nothing in the pc itself.

Because you are not sending keystrokes. THAT is done with the Keyboard library.

so is it doable? feel free to speak to me like a child, i really do know almost nothing.

if it is not feasible with the membrane button pad then i will build a board

Thanks

if it is not feasible with the membrane button pad then i will build a board

It IS feasible to get data from the button pad. But, what, EXACTLY, do you want to do with that data? Have you looked at the Keyboard library examples?

i have yes and to be honest, i though i was doing it correctly but it appears i wasnt.

The purpose of it for me, is to be able to map the numbers on the pad to in game commands on a racing game so i can turn my lights on/off winscreen wipers on/off etc.
I could use my keybord but if i can get this working, it will be a much better solution (space wise at least)

http://www.elecfreaks.com/estore/sealed-membrane-3-4-button-pad-with-sticker.html

You did not answer any of my questions. What are the labels on the keys? If the match what is in the code, what, EXACTLY, should happen when the '3' key is pressed?

If you want to execute a Keyboard.press('3'); when that happens, why don't you?

i can map in game controls to any key on my keyboard
an example would be keypad 3 turns my lights on / off
i would like to press number 3 on the button pad (the one in the earlier link) and have it register as the keyboard number 3
in my mind it sounds simple but i am not a coder so it would sound simple to me :wink:

i can adjust my seating position in game using wasd keys, i could remap them to 2,4,6,8 on number pad.

As i sit in a racing seat, i cant really reach my keyboard so this stick on pad would be an excellent replacement.

I have installed the keypad library and all works well within the arduino IDE but i am having trouble once i try to do anything outside of this.

I appreciate your patience and thank you for it

I have installed the keypad library and all works well within the arduino IDE but i am having trouble once i try to do anything outside of this.

Why are you trying to do anything outside of the IDE?

PaulS:
Why are you trying to do anything outside of the IDE?

im not, i am trying the code inside and the serial monitor shows my keystrokes. I want these keystrokes to show as actual keystrokes on the pc (ie. if i have my curser in the google search bar and i press 1 on my numberpad, i want it to show in the serch bar)

Not sure i have explained correctly. i want to control a game with it or at least an option within the game. i just want to press a button and it register as a keystroke.
i know this can be done with buttons and wiring and breadboards etc, i have seen videos but i can not get my button pad to register as a keystroke and see it as such anywhere outside of the serial monitor.

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.

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

I can't read the music format.

That's the Disney theme song. " I owe, I owe, so off to work i go...".

i think i owe you a coffee :slight_smile:

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

Keyboard.press(key);
    delay; 500, 
    Keyboard.release(key)

Thank you for your help (and patience)

Anyway, i removed Serial.print(key) and replaced it with

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