Hola espero me puedan ayudar con este pequeño proyecto, la idea es que cuando detecte los bits del 7 segmentos como entrada del puerto b, a la salida de puerto c y puerto d (esto con el pic16f877a), para el caso 0 sea el rc0=1 para el caso 1 sea en rc1= 1 asi hasta llegar al numero C que seria para el numero 12, adjunto la programacion que estoy ejecutando, pues logro corroborar que si funciona desde numero 5 hasta el C o 12 pero la parte del 1 al 4 no me logra responder o que me falta en esta programacion de antemano muchas gracias.
# include <16F877A.H>
# use delay(clock=4000000)
# fuses XT,NOWDT
# byte puerto_b=7 //Dirección del puerto b
# byte puerto_C=8 //Dirección del puerto c
# byte puerto_d=8 //Dirección del puerto d
void main() {
set_tris_C(0x00); //Configuro la puerta c como salida y RA0, RA1, RA2, RA3 y RA4 como
set_tris_d(0x00); //Configuro la puerta d como salida y RA0, RA1, RA2, RA3 y RA4 como
set_tris_b(0x1F); //entradas aunque por defecto ya están configuradas como entradas
puerto_b=0; //inicializo todos los bits de la puerta B a cero
puerto_c=0; //inicializo todos los bits de la puerta B a cero
puerto_d=0; //inicializo todos los bits de la puerta B a cero
while(true) //bucle infinito
{
if (input(PIN_b0)==false && input(PIN_b1)==false&& input(PIN_b2)==false&& input(PIN_b3)==false&& input(PIN_b4)==false&& input(PIN_b5)==false&& input(PIN_b6)==false)
{
puerto_c=0b00000000; //configura los bits de la puerta B caso 0 ain valor nulo
puerto_d=0b00000000; //configura los bits de la puerta B caso 0 ain valor nulo
}
if (input(PIN_b0)==false && input(PIN_b1)==true&& input (PIN_b2)==true&& input(PIN_b3)==false&& input(PIN_b4)==false&& input(PIN_b5)==false&& input(PIN_b6)==false)
{
puerto_c=0b00000001; //para el caso 1
}
if (input(PIN_b0)==true && input(PIN_b1)==true&& input (PIN_b2)==false&& input(PIN_b3)==true&& input(PIN_b4)==true&& input(PIN_b5)==false&& input(PIN_b6)==true)
{
puerto_C=0b00000010; //para el caso 2
puerto_d=0b00000000; //para el caso 1
}
if (input(PIN_b0)==true && input(PIN_b1)==true&& input(PIN_b2)==true&& input(PIN_b3)==true&& input(PIN_b4)==false&& input(PIN_b5)==false&& input(PIN_b6)==true)
{
puerto_C=0b00000100; //para el caso 3
}
if (input(PIN_b0)==false && input(PIN_b1)==true&& input(PIN_b2)==true&& input(PIN_b3)==false&& input(PIN_b4)==false&& input(PIN_b5)==true&& input(PIN_b6)==true)
{
puerto_C=0b00001000; //para el caso 4
puerto_d=0b00000000; //para el caso 1
}
if (input(PIN_b0)==true && input(PIN_b1)==false && input(PIN_b2)==true && input(PIN_b3)==true && input(PIN_b4)==false && input(PIN_b5)==true && input(PIN_b6)==true)
{
puerto_d=0b00000001; //para el caso 5
}
if (input(PIN_b0)==true && input(PIN_b1)==false && input(PIN_b2)==true && input(PIN_b3)==true && input(PIN_b4)==true && input(PIN_b5)==true && input(PIN_b6)==true)
{
puerto_d=0b00000010; //para el caso 6
}
if (input(PIN_b0)==true && input(PIN_b1)==true && input(PIN_b2)==true && input(PIN_b3)==false && input(PIN_b4)==false && input(PIN_b5)==false && input(PIN_b6)==false)
{
puerto_d=0b00000100; //para el caso 7
}
if (input(PIN_b0)==true && input(PIN_b1)==true && input(PIN_b2)==true && input(PIN_b3)==true && input(PIN_b4)==true && input(PIN_b5)==true && input(PIN_b6)==true)
{
puerto_d=0b00001000; //para el caso 8
}
if (input(PIN_b0)==true && input(PIN_b1)==true && input(PIN_b2)==true && input(PIN_b3)==true && input(PIN_b4)==false && input(PIN_b5)==true && input(PIN_b6)==true)
{
puerto_d=0b00010000; //para el caso 9
}
if (input(PIN_b0)==true && input(PIN_b1)==true && input(PIN_b2)==true && input(PIN_b3)==true && input(PIN_b4)==true && input(PIN_b5)==true && input(PIN_b6)==false)
{
puerto_d=0b00100000; //para el caso 0
}
if (input(PIN_b0)==true && input(PIN_b1)==true && input(PIN_b2)==true && input(PIN_b3)==false && input(PIN_b4)==true && input(PIN_b5)==true && input(PIN_b6)==true)
{
puerto_d=0b01000000; //para el caso A
}
if (input(PIN_b0)==true && input(PIN_b1)==false && input(PIN_b2)==false && input(PIN_b3)==true && input(PIN_b4)==true && input(PIN_b5)==true && input(PIN_b6)==false)
{
puerto_d=0b10000000; //para el caso C
}
}
}