rhee2
Newbie level 2
hello everybody,,
I've a problems in my project,,
I want to measure distance using ping ultrasonic sensor and PIC16f84a with 4Mhz xtall and display it in 8 bit data,, when the distance is 300cm led in PORTB show ffh
I've already made the program,, but this program doesn't run well,,
the counter is reset when the distance 125cm,,
the program list is below :
thanks for your attention,,
big respect,,
I've a problems in my project,,
I want to measure distance using ping ultrasonic sensor and PIC16f84a with 4Mhz xtall and display it in 8 bit data,, when the distance is 300cm led in PORTB show ffh
I've already made the program,, but this program doesn't run well,,
the counter is reset when the distance 125cm,,
the program list is below :
can you help me to fix this program,,,#include <htc.h>
#include <pic1684.h>
unsigned char a;
unsigned char c;
/*void interrupt isr()
{
TMR0=0;
c=TMR0;
if(T0IF!=1)
{
c++;
}
else if(T0IF==1)
{
T0IF=0;
}
T0IF = 0; /* Clear timer interrupt */
// }
void delay()
{
for(a=0; a<4; a++)
{}
}
void delay2()
{
for(a=0; a<1; a++)
{}
}
void delay1()
{
for(a=0; a<250; a++)
{}
}
void lambat()
{
a=254;
while(a<255)
{
a++;
}
}
void main()
{
unsigned char d;
TRISB=0x00;
PORTB=0x00;
//OPTION=0x07;
//INTCON=0xA0;
GIE=1;
while(1)
{
c=0;
//TMR0=0;
//c=TMR0;
T0IF=0;
TRISA=0x00;
RA2=1;
delay();
RA2=0;
delay1();
delay1();
delay1();
RA2=1;
delay();
TRISA=0x1f;
while(TRISA==0x1f)
{
// INTCON=0xA0;
while(RA2==1 && c<255)
{
c++;
#asm
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
#endasm
}
//PORTB=c;
while(RA2==0)
{PORTB=c;}
}
delay1();
}
}
thanks for your attention,,
big respect,,