Functional and working code

Followed a different example, code is now working.
Only half-duplex