I have a problem with receiving data. In the code I am trying to send binary data to digital pin thorugh which I want to receive and store them. This setup is on Arduino UNO where the two pins are connected together. I want to store them somehow through the pin change interrupt. I know that there have to be some kind of delay to know if there are two or more "1s" or "0s". I measured the high pulse width before and I got two different times when I tried it with ISR (16µs)and without ISR(8µs) .
so if the data is all 1s or all 0s, you might only get one interrupt
it might help to understand conventional serial transmission
a UART sends a ~byte of data, prefixed by a start bit and suffixed with one or 2 stops bits.
the start bit is the opposite of the idle line value so that there is a well defined change to indicate when a transmission begins.
bit times are well defined (e.g. 9600). bit timing is determined using a a timer
each bit is sampled one or more times (possibly voted to determine its state. if a single sample is used, the first delay based on the beginning of the start bit is 1.5 bit periods, and 1 bit period after that
stop bits are opposite the start bit state and guarantee that there is a change when start occurs and guarantees some amount of time between transissions
the # of bits transmitted is limited to tolerate ~2% overspeed and underspeed by both TX and RX.
this approach only relies on recognizing the change in state when the start bit occurs and uses timing to detect each bit.