# Just need 5 bits to differentiate symbols on 7seg display

You don’t need all 7 bits to differentiate symbols on 7 segments display.

I discovered it when I saw this project:
http://biphenyl.org/blog/?p=14

This guy soldered only few wires to read data from a breathalyzer, independently this other guy figure out we need only 5 bits to differentiate all symbols:
http://www.cibomahto.com/2008/02/how-many-unique-bits-in-a-seven-segment-display/

He wrote a python program to get the result. Then I converted it to C language:

```#include stdio /* arrggg wordpress shit */
/*
0bX1111111 = 0bXGFEDCBA
*/

unsigned char digits[10] = {0b00111111,
0b00000110,
0b01011011,
0b01001111,
0b01100110,
0b01101101,
0b01111101,
0b00000111,
0b01111111,
0b01101111};

void ptop(int i, unsigned char mask){
unsigned char dig = digits[i] & mask;

printf(" ");
if (dig & 0b1)
printf("_");
else
printf(" ");
printf("   ");
}

void pmid(int i, unsigned char mask){
unsigned char dig = digits[i] & mask;

if (dig & 0b100000)
printf("|");
else
printf(" ");

if (dig & 0b1000000)
printf("_");
else
printf(" ");

if (dig & 0b000010)
printf("|");
else
printf(" ");
printf("  ");
}

void pbtm(int i, unsigned char mask){
unsigned char dig = digits[i] & mask;

if (dig & 0b10000)
printf("|");
else
printf(" ");

if (dig & 0b1000)
printf("_");
else
printf(" ");

if (dig & 0b100)
printf("|");
else
printf(" ");
printf("  ");
}

{
int i;
for (i = 0; i < 10; i++)
printf("\n");
for (i = 0; i < 10; i++)
printf("\n");
for (i = 0; i < 10; i++)
printf("\n");

}

{
unsigned i, j;
for (i = 0; i < 10; i++)
for (j=i+1; j < 10; j++)
return 0;
return 1;

}

int main ()

{

unsigned char i;

for (i = 0; i < 128; i++){
if(stillUnique(i)){
printf("Funcionou para %i\n", i);
printdigit(i);
printf("\n\n");
}
}

}
```