Search code examples
c#bit-manipulationmicrocontroller8051

Converting an Ascii string to bit stream


I am doing a project in which i am getting data from some switches and push buttons on the pins of 8051 MC. Now i have to transmit serially, this data on the port pins, to the PC. At the PC end i am receiving the data in C# sharp .net application using the serial port class. Now the issue is that I want that the data received in C sharp application is in the form of bit string instead of Ascii.

Can someone guide me how it can be achieved ?


Solution

  • Something like this?

    byte b = 23;
    var str = Convert.ToString(b, 2).PadLeft(8,'0');