// 2400   -> 416.66
// 9600   -> 104.16
// 57600  -> 17.36
// 115200 -> 8.68

#define txPIN 1
#define bitTime 104

void setup() {
  
  Serial.begin(9600); // OVO JE POTREBNO SAMO KOD SIMULATORA !!!!
  Serial.end();       // OVO JE POTREBNO SAMO KOD SIMULATORA !!!!

  pinMode(txPIN, OUTPUT);
  digitalWrite(txPIN, HIGH);
  delay(100);
}


void sendSerial(byte n)
{
  byte bitmask=0x01;
  
  cli();
  PORTD &= 0b11111101;delayMicroseconds(bitTime); // START
  while(bitmask)
  {
    if(bitmask & n) PORTD |= 0b00000010;
     else PORTD &= 0b11111101;
     bitmask = bitmask<<1;
     delayMicroseconds(bitTime);
  }
  PORTD |= 0b00000010;delayMicroseconds(bitTime);
  sei();
}


void loop() {
  // put your main code here, to run repeatedly:

  sendSerial('Z');
  sendSerial('A');
  sendSerial('B');
  sendSerial('C');
  sendSerial('\n');
  delay(1000);

}