Hi Everyone,
I am currently trying to emulate a PS/2 keyboard using the ps2dev library from the bottom of the page here Arduino Playground - Ps2mouse
My plan was to use the play/pause etc buttons on an IR remote to make these commands on a PC to control iTunes and VLC.
The problem I am having is understanding these scan codes for the PS/2.
The code I found on the forums(can't find a link right now, will edit if I do) looks like this
void loop() {
unsigned char c;
//if host device wants to send a command:
if( (digitalRead(3)==LOW) || (digitalRead(2) == LOW)) {
while(keyboard.read(&c)) ;
keyboardcommand(c);
}
else{ //send keypresses accordingly using scancodes
// secancodes: http://www.computer-engineering.org/ps2keyboard/scancodes2.html
keyboard.write(0x1C); // \
keyboard.write(0xF0); // |- send 'a'
keyboard.write(0x1C); // /
delay (1000); // wait 1 second
}
}
I modified it to look like this so I could then select the key to press a play/pause command
//if host device wants to send a command:
if( (digitalRead(3)==LOW) || (digitalRead(2) == LOW)) {
while(keyboard.read(&c)) ;
keyboardcommand(c);
}
else{ //send keypresses accordingly using scancodes
// secancodes: http://www.computer-engineering.org/ps2keyboard/scancodes2.html
if(keyPressed == 1){
keyboard.write(0x34); // \
keyboard.write(0xE0); // |- send 'play/pause'
keyboard.write(0x34); // /
Serial.println(keyPressed);
keyPressed =0;
}
delay (1000); // wait 1 second
}
The first set of code does a constant pressing of 'a'.
The second set does a constant pressing of 'g' when I press the button on my remote, but doesn't stop. This part kind of makes sense as the code for it is 0x34, but the make/ break code setup confuses me a bit along with getting it to only press once.
Could someone give me a hand with putting the play/pause scancode in code for the Arduino that I could use?
Thanks a lot in advance!