beckhamho
Junior Member level 1
Hi
I am connected a missing pulse detector to pin2(RA0) of a PIC16f877a.
Basically the missing pulse detector will always given high output, and change to low output if sense missing pulse.It will change back to high after a short period. I need to write a program when the output change to low, the LCD will display number = 1. And the number will increase by one every time the output change to low. Below is the program i wrote, but it doesn't work.
the problem i facing is the above code couldn't work if combine with the LCD code. It could work if the code compile separately. below show the independent code that worked fine.
the next problem is below code didn't show any response in the LCD. i am trying to write the code that when the input is low, lcd on 1st row,13th digit will increase by one everytime the input change to low. Please figure out the problem for me.
Thanks for the help, really appreciate
I am connected a missing pulse detector to pin2(RA0) of a PIC16f877a.
Basically the missing pulse detector will always given high output, and change to low output if sense missing pulse.It will change back to high after a short period. I need to write a program when the output change to low, the LCD will display number = 1. And the number will increase by one every time the output change to low. Below is the program i wrote, but it doesn't work.
Code:
#include <16f877a.h>
#use delay(clock=20000000)
#fuses hs,noprotect,nowdt,nolvp
#define use_portb_lcd TRUE
#include <lcd.c>
#define PWR_LED Pin_A5
#define IR1 Pin_A0
void main()
{
int interrupt = 0;
SETUP_ADC_PORTS(NO_ANALOGS);
setup_adc(adc_off);
lcd_init();
{
if (input(IR1) == True) /this code is used for check H or L using a LED
output_high(PWR_LED);
else
output_low(PWR_LED);
lcd_putc("\fAutomatic Room");
lcd_putc("\nLight Controller");
delay_ms(5000);
lcd_putc("\f");
lcd_gotoxy(1,1);
lcd_putc("People in = \n");
if(input(IR1)==0) / if the input is low
{
interrupt+=1; increment by one
lcd_gotoxy(13,1); display on first row,13th column
lcd_putc(interrupt);
}
}while(1);
}
Code:
if (input(IR1) == True) /this code is used for check High or Low using a LED
output_high(PWR_LED);
else
output_low(PWR_LED);
the problem i facing is the above code couldn't work if combine with the LCD code. It could work if the code compile separately. below show the independent code that worked fine.
Code:
#include <16F877a.h>
#use delay(clock=20000000)
#fuses HS, NOWDT, NOPROTECT, NOPUT, NOLVP
#define PWR_LED Pin_A5
#define IR1 Pin_A0
void main()
{
While(1)
{
if (input(IR1) == True)
output_high(PWR_LED);
else
output_low(PWR_LED);
}
}
the next problem is below code didn't show any response in the LCD. i am trying to write the code that when the input is low, lcd on 1st row,13th digit will increase by one everytime the input change to low. Please figure out the problem for me.
Code:
if(input(IR1)==0) / if the input is low
{
interrupt+=1; increment by one
lcd_gotoxy(13,1); display on first row,13th column
lcd_putc(interrupt);
}
}while(1);
Thanks for the help, really appreciate