Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <16F886.h>
- #use delay(internal = 8M)
- #FUSES NOWDT //No Watch Dog Timer
- #FUSES INTRC_IO //#FUSES INTRC_IO
- #FUSES NOPUT //No Power Up Timer
- #FUSES NOMCLR //Master Clear pin used for I/O
- #FUSES NOPROTECT //Code not protected from reading
- #FUSES NOCPD //No EE protection
- #FUSES NOBROWNOUT //No brownout reset
- #FUSES NOIESO //Internal External Switch Over mode disabled
- #FUSES NOFCMEN //Fail-safe clock monitor disabled
- #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
- #FUSES NODEBUG //No Debug mode for ICD
- #FUSES BORV40 //Brownout reset at 4.0V
- #FUSES NOWRT //Program memory not write protected
- #use fast_io(A)
- #use fast_io(B)
- #use fast_io(C)
- #define PORTC 0x07
- #define LCD_PinRS PIN_B0
- #define LCD_PinEnable PIN_B1
- #define LCD_BusDatos PORTC //utiliza la parte baja del puerto
- #include <lcd_custom.c>
- char mensaje[33];
- void main()
- {
- int16 count =0;
- setup_adc_ports(NO_ANALOGS|VSS_VDD);
- setup_adc(ADC_OFF);
- setup_spi(FALSE);
- setup_oscillator(OSC_8MHZ);
- 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);
- set_tris_a(0x00);
- set_tris_b(0x00);
- set_tris_c(0x10);
- delay_ms(100);
- output_a(00);
- output_b(00);
- output_c(0x00);
- output_high(PIN_C5);//test
- lcd_Inicializa();
- strcpy(mensaje,"hola mundo");
- mensaje_lcd(mensaje);
- delay_ms(2000);
- strcpy(mensaje,"contador de pulsos:");
- mensaje_lcd(mensaje);
- delay_ms(2000);
- count = 1;
- while(1)
- {
- if(bit_test(input_c(),4)==0)
- {
- delay_ms(100);// evitar debounce
- if(bit_test(input_c(),4)==0)
- {
- sprintf(mensaje,"%3Lu",count);
- mensaje_lcd(mensaje);
- count++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement