Sunteți pe pagina 1din 8

#include <16f877a.

h>
#fuses XT,NOWDT,PUT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,NODEBUG,NOPROTECT
#USE DELAY (CLOCK=4000000)
#use standard_io(b)
#USE standard_IO(d)
#use standard_IO(c)
void llamartabla (int direccion){
switch (direccion){
case 0:
output_B(0b00000000);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 1:
output_B(0b00000001);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 2:
output_B(0b00000010);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 3:
output_B(0b00000011);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 4:
output_B(0b00000100);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 5:
output_B(0b00000101);
OUTPUT_HIGH(PIN_C1);

OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 6:
output_B(0b00000110);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 7:
output_B(0b00000111);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 8:
output_B(0b00001000);
OUTPUT_LOW(PIN_C0);
OUTPUT_HIGH(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 9:
output_B(0b00001001);
OUTPUT_LOW(PIN_C0);
OUTPUT_HIGH(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 10:
output_B(0b00001010);
OUTPUT_LOW(PIN_C0);
OUTPUT_HIGH(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 11:
output_B(0b00001011);
OUTPUT_LOW(PIN_C0);
OUTPUT_HIGH(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;

case 12:
output_B(0b00001100);
OUTPUT_LOW(PIN_C0);
OUTPUT_HIGH(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 13:
output_B(0b00001101);
OUTPUT_LOW(PIN_C0);
OUTPUT_HIGH(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 14:
output_B(0b00001110);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 15:
output_B(0b00001111);
OUTPUT_HIGH(PIN_C1);
OUTPUT_LOW(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 16:
output_B(0b00000000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 17:
output_B(0b00010000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 18:
output_B(0b00100000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);

OUTPUT_HIGH(PIN_C1);
BREAK;
case 19:
output_B(0b00110000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 20:
output_B(0b01000000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
BREAK;
case 21:
output_B(0b01010000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 22:
output_B(0b01100000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 23:
output_B(0b01110000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 24:
output_B(0b10000000);
OUTPUT_HIGH(PIN_C0);
OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 25:
output_B(0b10010000);
OUTPUT_HIGH(PIN_C0);

OUTPUT_LOW(PIN_C1);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 26:
output_B(0b10100000);
OUTPUT_LOW(PIN_C1);
OUTPUT_HIGH(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 27:
output_B(0b10110000);
OUTPUT_LOW(PIN_C1);
OUTPUT_HIGH(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 28:
output_B(0b11000000);
OUTPUT_LOW(PIN_C1);
OUTPUT_HIGH(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 29:
output_B(0b11010000);
OUTPUT_LOW(PIN_C1);
OUTPUT_HIGH(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
case 30:
output_B(0b11100000);
OUTPUT_LOW(PIN_C1);
OUTPUT_HIGH(PIN_C0);
DELAY_us(500);
OUTPUT_HIGH(PIN_C0);
OUTPUT_HIGH(PIN_C1);
break;
}
}
void letraj (int direccion){
output_d(0b10111011);
llamartabla (direccion+0);
output_d(0b10111011);
llamartabla (direccion+1);
output_d(0b10000011);

llamartabla (direccion+2);
}
void letrah (int direccion){
output_d(0b10000011);
llamartabla (direccion+0);
output_d(0b11101111);
llamartabla (direccion+1);
output_d(0b11101111);
llamartabla (direccion+2);
output_d(0b10000011);
llamartabla (direccion+3);
}
void letrao (int direccion){
output_d(0b10000011);
llamartabla (direccion+0);
output_d(0b10111011);
llamartabla (direccion+1);
output_d(0b10000011);
llamartabla (direccion+2);
}
void letran (int direccion){
output_d(0b10000011);
llamartabla (direccion+0);
output_d(0b11110111);
llamartabla (direccion+1);
output_d(0b11101111);
llamartabla (direccion+2);
output_d(0b11011111);
llamartabla (direccion+3);
output_d(0b10000011);
llamartabla (direccion+4);
}
void letrad (int direccion){
output_d(0b10000011);
llamartabla (direccion+0);
output_d(0b10111011);
llamartabla (direccion+1);
output_d(0b11000111);
llamartabla (direccion+2);
}
void letraa (int direccion){
output_d(0b10000011);
llamartabla (direccion+0);
output_d(0b11110101);
llamartabla (direccion+1);
output_d(0b10000011);
llamartabla (direccion+2);
}
void letrai (int direccion){
output_d(0b10000011);
llamartabla (direccion+0);
}
void animacion(int direccion){
output_d(0b11001111); // inicio aniimacion
llamartabla(direccion);
output_d(0b11001111);
llamartabla(direccion+1);
output_d(0b10000001);
llamartabla(direccion+2);

output_d(0b11011011);
llamartabla(direccion+3);
output_d(0b11011011);
llamartabla(direccion+4);
output_d(0b10000011);
llamartabla(direccion+5);
output_d(0b11001111);
llamartabla(direccion+6);
output_d(0b11001111);
llamartabla(direccion+7);
}
void animacion2(int direccion){
output_d(0b11001111); // inicio aniimacion
llamartabla(direccion);
output_d(0b11001111);
llamartabla(direccion+1);
output_d(0b10000001);
llamartabla(direccion+2);
output_d(0b11011011);
llamartabla(direccion+3);
output_d(0b11011011);
llamartabla(direccion+4);
output_d(0b10000011);
llamartabla(direccion+5);
output_d(0b11001111);
llamartabla(direccion+6);
output_d(0b11001111);
llamartabla(direccion+7);
}
void main (){
int contador=0;
int direccion=0;
int tabla=0;
int h=0;
while(1){
letraj(direccion);
letrah(direccion+4);
letrao(direccion+9);
letran(direccion+13);
letrad(direccion+19);
letraa(direccion+23);
letran(direccion+27);
letrai(direccion+32);
switch (h){
case 0:
animacion(direccion+38);
break;
case 1:
animacion2(direccion+48);
break;
default:
break;

}
contador++;
if (contador==10){
contador=0;
direccion=direccion-1;
h++;
if (h==3){
h=0;
}
}
}
}

S-ar putea să vă placă și