Arduino freezes trying to send OSC signal while using PS2Keyboard Library

Hi all,

I’ve set up an old qwerty PS2 Keyboard on my Uno using the libraries from here: PS2Keyboard Library, Connect a keyboard for user input

I’m trying to send OSC messages to my PC (running TouchDesigner) after the Arduino registers a keystroke, but it freezes up while trying to send the OSC message. Here is some test code I’ve been working with:

#include <PS2Keyboard.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>    
#include <OSCMessage.h>

EthernetUDP Udp;

//the Arduino's IP
IPAddress ip(192, 168, 0, 2);
//destination IP
IPAddress outIp(192, 168, 0, 1);
const unsigned int outPort = 10000;

 byte mac[] = {  
  0xDE, 0xAD, 0xBB, 0xBA, 0xAA, 0xAA };

const int DataPin = 2;
const int IRQpin =  3;

PS2Keyboard keyboard;

void setup() {
  keyboard.begin(DataPin, IRQpin);
  Serial.println("Keyboard Test:");  //using serial for testing only

void loop() {
  if (keyboard.available()) {
    // read the next key
    char c =;
    // check for key press
    if (c == PS2_LEFTARROW) {
       OSCMessage msg("/LEFTARROW");
      Udp.beginPacket(outIp, outPort);
      msg.send(Udp); // send the bytes to the SLIP stream
      Udp.endPacket(); // mark the end of the OSC Packet
      msg.empty(); // free space occupied by message
    } else {
      // otherwise, just print all normal characters

After doing a bit of research, I get the impression that the interrupt used by the Keyboard libraries is stalling out because of the OSC sending protocols. I’m pretty new to arduino in general, but I’ve read a bit about interrupts and how they work, but I can’t quite get my head around how to get this to work right.

Any advice would be greatly appreciated!



Never mind, I just forgot

void setup() {