Go Down

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

wodm

Sep 06, 2015, 06:59 pm Last Edit: Sep 06, 2015, 08:09 pm by wodm
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.

Code: [Select]
/* @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);
  }
}

PaulS

Quote
Is it possible
Not unless you can figure out how to install Notepad on the Arduino.
The art of getting good answers lies in asking good questions.

wodm

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.

PaulS

Which Arduino do you have? Only the discontinued Leonardo and the Micro have the hardware to send keystrokes. The others can not.
The art of getting good answers lies in asking good questions.

wodm

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

PaulS

The teensy or the Micro will work. So, what is the problem?
The art of getting good answers lies in asking good questions.

wodm

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

PaulS

Quote
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.
The art of getting good answers lies in asking good questions.

wodm

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

PaulS

Quote
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?
The art of getting good answers lies in asking good questions.

wodm

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


PaulS

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?
The art of getting good answers lies in asking good questions.

wodm

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

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

PaulS

Quote
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?
The art of getting good answers lies in asking good questions.

wodm

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.

Go Up