Hello everybody.
Recently I was testing the ps2keyboard library but for my project I need something that I think that the library does not have:
I need my arduino to know when a key is pressed and when a key is released, like if I had a push button on a digital pin.
I'm using this simple code:
#include <PS2Keyboard.h>
const int DataPin = 8;
const int IRQpin = 3;
PS2Keyboard keyboard;
void setup() {
delay(1000);
keyboard.begin(DataPin, IRQpin);
Serial.begin(9600);
pinMode(10, OUTPUT);
}
void loop() {
if (keyboard.available()) {
digitalWrite(10, HIGH);
// read the next key
char c = keyboard.read();
Serial.print(c);
}
else {
digitalWrite(10, LOW);
}
}
So my point is: I need that when a key is pressed, the pin 10 would be constantly HIGH. And would turn LOW only when the key is released. Can somebody help me with that?