title: Baud rate on Arduino
body: <p>I am implementing a simple visible light communication module with two Arduinos, as a transmitter and a receiver, with a short text message consisting of 120 characters. I have used <a href="https://en.wikipedia.org/wiki/Manchester_code" rel="nofollow noreferrer">Manchester encoding</a> with on-off -keying modulation.</p>
  <p>Altogether, in my message frame, with Manchester encoding and with preambles and end-of-frame byte, there are 2480 bits. I have set one bit period to be 500 microseconds. On the receiver side, I am sampling this bit four times, at (500/4) 125 microseconds. From my knowledge, since each bit is 500 μs, there are 2000 bits/s that are being transmitted from the transmitter so a baud rate of 9600 bits/s should work. However, 9600 is not working and any baud rate above 38400 up to 115200 is working, and I can properly decode this short message in my receiver.</p>
  <p>What is the explanation for this behavior? Why is baud rate of 9600 not working though I am only transmitting 2000 bits per second?</p>
  <p>Further information: I have set the prescalar to 128, so the <a href="https://en.wikipedia.org/wiki/Analog-to-digital_converter" rel="nofollow noreferrer">ADC</a> sampling frequency is (16 MHz/128)/13 = 9.6 kHz.</p>