   delayMicroseconds(2);
 
   // Enter key sequence on PGD
-  for (int n = 0; n < 32; n++) {    
+  for (int n = 0; n < 32; n++)
+  {
     //Lower PGC and write bit to PGD
     digitalWrite(PGC, LOW);
     digitalWrite(PGD, keyseq[n]);
     delayMicroseconds(1);
-    
+
     //Raise PGC to send bit
     digitalWrite(PGC, HIGH);
     delayMicroseconds(1);

#define PGD 5
#define PGC 6

int keyseq[]  = {0,1,0,0, 1,1,0,1, 0,1,0,0, 0,0,1,1, 0,1,0,0, 1,0,0,0, 0,1,0,1, 0,0,0,0};

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(57600);

  // Wait for serialUSB or start after 30 seconds
  while ((!SerialUSB) && (millis() < 30000));
  SerialUSB.write("SerialUSB set up\r\n");

  // Initialize LED

}

// Serial program/verify operation
int sendOp(int cmd, int payload)
{
  bool valid = true;
  bool isread = false;

  // Check if command is valid and if it contains a read
  switch (cmd)
  {
  case B0000:
    break;
  case B0010:
    isread = true;
    break;
  case B1000:
    isread = true;
    break;
  case B1001:
    isread = true;
    break;
  case B1010:
    isread = true;
    break;
  case B1011:
    isread = true;
    break;
  case B1100:
    break;
  case B1101:
    break;
  case B1110:
    break;
  case B1111:
    break;
  default:
    valid = false;
  }

  // Check if data payload is the right size
  if ((isread && (payload > 255)) || (!isread && (payload > 65535)))
  {
    SerialUSB.write("Invalid number of payload bits\r\n");
    return false;
  }

  if (valid)
  {
    // Send command bits to the RN2483
    for (int n = 0; n < 4; n++)
    {
      //Lower PGC and write bit to PGD
      digitalWrite(PGC, LOW);
      digitalWrite(PGD, bitRead(cmd, n));
      delayMicroseconds(1);

      //Raise PGC to send bit
      digitalWrite(PGC, HIGH);
      delayMicroseconds(1);
