Resolução:
CÓDIGO FEITO EM CCS C COMPILER
#include <16F877A.h>
#device ADC = 8
#use delay(crystal = 20MHz)
#define tempo 400
int v1[] = {0b00111111, 0b00000110, 0b01011011, 0b01001111, 0b01100110, 0b01101101, 0b01111101, 0b00000111, 0b01111111, 0b01100111};
int tam = sizeof(v1)/sizeof(int);
void contador(int valor1){
output_b(0b00111111);
output_d(0b01111111);
delay_ms(1000);
for(int i = valor1; i < tam; i++){
output_d(v1[i]);
delay_ms(tempo);
}
for(i = 1; i < tam; i++){
for(int j = 0; j < tam; j++){
output_b(v1[i]);
output_d(v1[j]);
delay_ms(tempo);
}
}
}
void main(){
contador(8);
while(true){
delay_ms(1000);
for(int i = tam; i > 0; i--){
for( int j = 10; j > 0; j--){
output_b(v1[i-1]);
output_d(v1[j-1]);
delay_ms(tempo);
}
}
delay_ms(1000);
for (i = 0; i < tam; i++){
for( int j = 0; j < tam; j++){
output_b(v1[i]);
output_d(v1[j]);
delay_ms(tempo);
}
}
}
}
Resolução 2 feita em no PicSimlab
Código feito em CCS C Compiler
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES LP //Low power osc < 200 khz
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#use delay(clock = 20MHz)
#define delay 50
unsigned int i = 0, tempo, cont = 8;
byte const luz [10]={
0b0111111, //0
0b0000110, //1
0b1011011, //2
0b1001111, //3
0b1100110, //4
0b1101101, //5
0b1111101, //6
0b0100111, //7
0b1111111, //8
0b1101111 //9
};
byte const display []={
0b000000, // display desligado
0b000100, // display 1
0b001000, // display 2
0b010000, // display 3
0b100000, // display 4
0b1101101, //5
0b1111101, //6
0b0100111, //7
0b1111111, //8
};
void main(){
while(true){
for(tempo = 0; tempo < 10; tempo++){
i = cont/10;
output_a(display[7]);
output_d(luz[i]);
delay_ms(delay);
i = cont%10;
output_a(display[4]);
output_d(luz[i]);
delay_ms(delay);
}
if(++cont >= 100)cont = 8;
}
}
Nenhum comentário:
Postar um comentário