# How to decide which key was pressed on a calculator?

Hi all,

I'm trying have an arduino read key presses on my calculator. The calculator does it by pressing the keyboard membrane to the PCB and connecting two points, so each key has two of these points. I've soldered wires to two key's contact points(four wires in total), and connected the arduino's GND to the calculator's -ve.

I read the values in analog, then calculate the voltage, so I would see a change in voltage, when a key is pressed, and the key would be identified by which contact point had the v. change happens on.

Now here's what actually happens... Every contact point has a voltage change(to an equal degree, too) when either key is pressed. One and three jumps to 1.4, two and four jumps to 0.0.

There's a chance I somehow damaged the circuit, but other than that, I have no idea what I'm doing wrong...

Here's my code:

int one = A0;
int two = A1;
int three = A2;
int four = A3;

float refVolt = 5.0;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:

float oneV = (oneR/1023.0)*refVolt;
float twoV = (twoR/1023.0)*refVolt;
float threeV = (threeR/1023.0)*refVolt;
float fourV = (fourR/1023.0)*refVolt;

Serial.println("One: "+(String)oneV+" - Two: "+(String)twoV+" - Three: "+(String)threeV+" - Four: "+(String)fourV);

delay(100);

}


PCB with the wired points marked: If this is how the whole thing should work, is there any way to read and decide which key was pressed? If my way should work, what am I doing wrong, and how can I fix it?

• Aren't points four and two on the same copper trace already? The keyboard is most likely scanned in a mateix of rows and columns, so just reading the time-averaged analog voltages can look identical for each button. May 21, 2020 at 12:45
• We need some background information. Do you understand how keyboard multiplexing works? May 21, 2020 at 12:45
• @Transistor no, I sadly don't. I've read about it when starting the project, but thought it's not necessary to know for this. May 21, 2020 at 12:47
• @Justme Oh... Alright, that makes sense. I should've seen that, sorry. Do you know another way? May 21, 2020 at 12:49
• You can't interpret the signals unless you understand how they're generated. I think you need to go back and do the reading. May 21, 2020 at 12:53

This will not answer your question but will give you some background information why your project will be difficult. Figure 1. Keyboard scanning matrix. Image source: The Cuckoo's Nest.

• The animation is showing that (for this example) the rows are switched on in sequence 0, 1, 2, 0, 1, 2, ....
• If a key is pressed then that COLumn will turn high.
• To know which key was pressed you have to know:
• Which ROW output is on.
• Which COLumn input is on.

So for you to do this you need to monitor each row and column and you have to be faster than the calculator so analog might not be a good idea. The problem is more difficult because the calculator is probably not the same voltage as your micro-controller.

This might not be worth the trouble!

• Thank you, great explanation! May 21, 2020 at 18:27