Sunteți pe pagina 1din 2

#include <16F628A.

h> #FUSES NOWDT //No Watch Dog Timer #FUSES INTRC_IO //Internal RC Osc, no CLKOUT #FUSES NOPUT //No Power Up Timer #FUSES NOPROTECT //Code not protected from reading #FUSES NOBROWNOUT //No brownout reset #FUSES NOMCLR //Master Clear pin used for I/O #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O #FUSES NOCPD //No EE protection #FUSES RESERVED //Used to set the reserved FUSE bits #use delay(clock=4000000) //#use rs232(baud=9600,parity=N,xmit=PIN_A3,rcv=PIN_A2,bits=8) #use standard_io(A) #use standard_io(B) #define PASO1 PIN_B0 // se define el nombre de la patilla #define PASO2 PIN_B1 // se define el nombre de la patilla #define PASO3 PIN_B2 // se define el nombre de la patilla #define PASO4 PIN_B3 // se define el nombre de la patilla #define SGIRO PIN_A1 // se define el nombre de la patilla

void main() { setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); //Setup_Oscillator parameter not selected from Intr Oscillator Config tab // TODO: USER CODE!! set_tris_b(0b00000000);//TODOS LOS PINES COMO SALIDAS set_tris_a(0b00000101);//el pin A0,A1,A2 como entrada el resto como salida OUTPUT_B(0b00000000);//apaga todos los pines del puerto B //OUTPUT_A(0b00000000); byte const numeroled[10]={0b0000,0b0001,0b0010,0b0011,0b0100,0b0101,0b0110,0b0111,0b1000,0b1001} ; long tiempo;//teneR cuidado con el tipo de dato //yo puse aqui float y no funcionaba el pic tiempo=500;//el tiempo se da en milisegundos int contador; contador=0; OUTPUT_B(numeroled[0]);//elled empieza encendido en 0 byte ud=0, dec=0, cent=0; while(true){ //este es un metodo muliplexando los pines del puerto b para dos digitos

for(cent=0;cent<10;cent++){//para cpntar centenas for(dec=0;dec<10;dec++){ for(ud=0;ud<10;ud++){ //output_a(0x02);//decenas apagado ,unidades prendido

output_high(pin_a7);//unidades prendido a7 output_low(pin_a6);//decenas apagado a6 output_low(pin_a4);//centemas apagado a4 output_b(numeroled[ud]);//saco el numero por el led de las unidades delay_ms(50); //aca acciono al led de las decenas if(dec==0) output_low(pin_a6);//led de decenas apagado else { output_high(pin_a6);//led decenas encendido output_low(pin_a7);//led unidades apagado output_low(pin_a4);//centemas apagado a4 output_b(numeroled[dec]); delay_ms(50); } //aca acciono al led de las centenas if(cent==0) output_low(pin_a4);//led de centenas apagado else { output_low(pin_a7);//led unidades apagado a7 output_low(pin_a6);//led decenas apagado a6 output_high(pin_a4);//led centemas encendido a4 output_b(numeroled[cent]); delay_ms(50); }

} } }

} }

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