Download SimSat Educational Program Development
Transcript
int convertBinary(int binary) {
/* This function takes the raw binary Byte that was read from the parallel
port
as the ADC output and converts it to a useable integer.
int status - This is the integer value that contains the output of the
ADC.
We can check to see if each of the data bits is set, and output the
appropriate bit value.
*/
int decimal = 0;
if (binary & DATA7)
decimal += 128;
if (binary & DATA6)
decimal += 64;
if (binary & DATA5)
decimal += 32;
if (binary & DATA4)
decimal += 16;
if (binary & DATA3)
decimal += 8;
if (binary & DATA2)
decimal += 4;
if (binary & DATA1)
decimal += 2;
if (binary & DATA0)
decimal += 1;
return(decimal); // Return the decimal (integer) conversion of the
binary byte
}
107