       case '0': {
         if (sequenceAt < sequenceSize) {
           sequence[sequenceAt++] = 0;
+        } else {
+          Serial.println("Sequence is too long");
         }
       } break;
       case '1': {
         if (sequenceAt < sequenceSize) {
           sequence[sequenceAt++] = 1;
-        }
+        } else {
+          Serial.println("Sequence is too long");
+        }
+      } break;
+      case 'b': {
+        sequenceAt = 0;
+        sequenceAtBit = 0;
+        inBinarySequence = true;
       } break;
       case ';': {
         if (!prevSequenceSize || sequenceAt > 0) {

  digitalWrite(out, HIGH);
  digitalWrite(debug, HIGH);
  Serial.begin(9600);
}

void sendSequence(const char* seq)
{
  Serial.println("Sending sequence");
  static unsigned long time = micros();

    }
  }
}

void advanceBit() {
  if (++sequenceAtBit == 8) {
    ++sequenceAt;
    sequenceAtBit = 0;
  }
  if (sequenceAt == sequenceSize) {
    inBinarySequence = false;
  }
}

void binarySequenceLoop() {
  if (Serial.available()) {
    char ch = Serial.read();
    switch (ch) {
      case '1': {
        sequence[sequenceAt] |= (1 << sequenceAtBit);
        advanceBit();
      } break;
      case '0': {
        sequence[sequenceAt] &= ~(1 << sequenceAtBit);
        advanceBit();
      } break;
      case ';': {
        Serial.print("Sending binary ");
        Serial.print(sequenceAt * 8);
        Serial.print("+");
        Serial.print(sequenceAtBit);
        Serial.println(" bits");
        sendBinarySequence(sequence, sequenceAt * 8 + sequenceAtBit);
        inBinarySequence = false;
      } break;
      default:
        Serial.println("Aborting binary sequence");
        inBinarySequence = false;
    }
  }
}

void loop() {
  if (inBinarySequence) {
    binarySequenceLoop();
    if (!inBinarySequence) {
      sequenceAt = 0;
      prevSequenceSize = 0;
    }
  } else {
    baseLoop();
  }
}
