
#include <SoftwareSerial.h>

SoftwareSerial mySerial(6, 7);

void setup() {
  Serial.begin(1200); // serial port to the computer
  mySerial.begin(1200); // serial port to the minitel
}

void serialprint7(byte b) { // 7 bits + parity on SoftwareSerial
  boolean  i = false;
  for(int j = 0; j<8 ; j++) if (bitRead(b,j)==1) i=!i; // check parity
  if (i) bitWrite(b,7,1); // writes parity
  else bitWrite(b,7,0);
  mySerial.print(b);// writes byte
}

void loop() { // transmits everything that goes in the computer serial to the minitel one
  byte b = 255;
  while (b == 255) b = Serial.read();
  serialprint7(b);
}

