please help me with pic16f877a

Status
Not open for further replies.

xairz

Newbie level 2
Joined
May 10, 2011
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,299
im having problem to light on led using irpd sensor . can anyone help how to make the led on . this is my coding . please . help me anyone :-(

Code:
#include <16f877a.h>
#device adc=8
#use delay(clock=20000000)
#fuses hs,noprotect,nowdt,nolvp
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,parity=N)

#byte PORTa=5
#byte PORTb=6
#byte PORTC=7
#byte PORTd=8
#byte PORTe=9

void main()
{
int value1,value2;
//set_tris_b(0b00000000);
set_tris_d(0b00000000);
setup_port_a(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);


do
{
set_adc_channel(0);
value1=read_adc();
//printf("read S %u",value1);
delay_ms(1000);
portd = value1;


set_adc_channel(1);
value2=read_adc();
//printf("read S %u",value2);
delay_ms(1000);
portd = value2;


if(value1 > 1)
{

output_high(pin_D7);
//delay_ms(1000);
}
else
{
output_low(pin_D6);
//delay_ms(1000);
//output_low(pin_D5);
}

}
while(1);
}

your help means a lot to me
 

is your adc set correctly?
 

whats problem in your code. I mean what you want to do..
 

which is the compiler you using?
what is the problem ?
what is the output now?
 
Reactions: xairz

    xairz

    Points: 2
    Helpful Answer Positive Rating
john : yes , i set it correctly . do you think it set wrong ?

rajbabu : i don't know . im using an irpd sensor . it just like ir sensor . when it detect object or obstacle , led will light on .

thunder : im using ccs , the problem is when on the board . nothing happen . the sensor also not light on , the output should make led on . but nothing happen

this is sensor im been using

IRPD-01 IR Proxinity Detector - discover electronics and robotics
 

Their may be two problem:
1. in hardware
check output of sensor without connecting to uC.
if it is coming right then conect to uC and check.
if output of sensor deviating from previous value then add pull up resistance on that pin.
2. in software
make input pin to it or change pin.

Rajbabu
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…