• 0

[C#] Convert Byte To Binary


Question

4 answers to this question

Recommended Posts

  • 0

sure, but doubt this will help others.. Needed this for a program i was writing to turn on 8 separate LED's attached to my parallel port. (heres a video of it.. http://www.youtube.com/watch?v=Fq-TzxaW-IQ )

this code was to get the status off the parallel port (which Inp32() returns as a byte value (0 - 255)) to a Binary value.. so I'm willing to bet this will need to be modified for others to get it to work... and the Binary is probably reversed.. i lost interest in making this since i don't have a 25 pin cable to take the parallel port from the back of my comp to the front... at least not yet.. only cable i have is a 25 male to male cable which i don't want to destroy.

void monitor(object o2, EventArgs e2)
		{
			string binary = "";
			byte bite;
			bite = Inp32(Program.address);
			for (int i = 0; i <= 7; i++) {
				if ((bite & (int)Math.Pow(2, i)) != 0)
				{
					binary += "1";
					Program.chkBox[i].Checked = true;
				}
				else
				{
					binary += "0";
					Program.chkBox[i].Checked = false;
				}
			}
			toolStripStatusLabel1.Text = binary + " [" + bite +"]";
		}

  • 0
You could also get a converter.....but seeing as those cables arent used as much now I suppose you could grab one on the cheap.....if your desperate try ebay!

GE

yea i was thinkin about that, (they're called Gender Changers. and would need one for DB25 (25 pin Parallel Port))

The radio shack nearby doesn't carry them, and no other stores that would carry them nearby.. but probably just gonna order one online..

My initial theory for this project was simple... 8 LED's.. assign 1 LED per friend.. then have my program get unread IM's from Pidgin (probably code a plugin to do that).. and light the LED for that friend (mainly so i don't have to minimize the game i'm playing to see who IM'ed me)... or even take it further and do other simple stuff like Download Progress... 2 LEDs = 25%, 4 LEDs = 50%, 8 LEDs = 100%..

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.