| |
/********************************
*This program takes the numbers *
*in the string, encodes them for*
*the display, activates the *
*correct display and sends the *
*code out *
********************************/
#include <stdio.h>
#include <reg51.h>
char numbers[] = {0,1,2,3};
char encode (char num);
void main (void){
int i = 0;
int select = 1;
while (1){
P2 = encode(numbers[i]);
P1 = ~select;
select = select * 2;
if (select > 8){
select=1;
}
i++;
if(i == 4){
i=0;
}
}
}
char encode (char num){
if (num == 0)
return (~1);
if (num == 1)
return (~79);
if (num == 2)
return (~18);
if (num == 3)
return (~6);
if (num == 4)
return (~76);
if (num == 5)
return (~36);
if (num == 6)
return (~32);
if (num == 7)
return (~15);
if (num == 8)
return (0);
if (num == 9)
return (~12);
}
|