Help pic programming

Thread Starter

mattlove

Joined Dec 15, 2009
4
need help..
i am currrently trying to prgram my pic to receive a signal from sensor then just to put out an output. out put is just LED
void main(void)
{
TRISA=0b11111111; //set PORTB as input
TRISB=0b11111111; //set PORTC as output
TRISC=0b00000000;
TRISD=0b00000000;
RD3=1;

{
if(RB5==0)
{
RC3=1;
}
else if (RB5==1)
{
RC3=0;
}
}
}
this is my programming.. how come the RC# does not lie up at all???
can any1 help me pls
 

S_lannan

Joined Jun 20, 2007
246
seems to me the program would just poll the rb5 input once and thats it.

if you put an infinite loop such as a while(1) the program would continously poll. like this

void main(void)
{
TRISA=0b11111111; //set PORTB as input
TRISB=0b11111111; //set PORTC as output
TRISC=0b00000000;
TRISD=0b00000000;
RD3=1;

while(1)
{
if(RB5==0)
{
RC3=1;
}
else if (RB5==1)
{
RC3=0;
}
}
}
 

Thread Starter

mattlove

Joined Dec 15, 2009
4
okie lets make it easy. i wanna have a output after getting an input signal.. how come can i make it with rb7 as input. but if i change the input to rb5 or others, the output like rc2 is always on.. nothing happens... pls i need help
 

Thread Starter

mattlove

Joined Dec 15, 2009
4
//============================================================================
// Include
//============================================================================
#include <pic.h>
#include "delay.h"
#include "delay.c"
//============================================================================
// Configuration
//============================================================================
__CONFIG ( 0x3F32 );
//============================================================================
// Define
//============================================================================
//============================================================================
// Function Prototype
//============================================================================
void control(void);
//============================================================================
// global variable
//============================================================================
//============================================================================
// Main Function
//============================================================================
void main(void)
{

TRISA=0b11111111; //set PORTB as input
TRISB=0b11111111; //set PORTC as output
TRISC=0b00000000;
TRISD=0b11111111;
RC4=1;
RC5=1;

{
control();
}
}
//================================================================================
// FUNCTIONS
//================================================================================
void control(void)
{
if (RB7==1)
{
RC3=1;

}
else
{
RC3=0;

}
}

if i change the input part RB7 to RB6 or other ports, the RC3 will keep on lite up.. it wont turn off... i suspect its got somehintg to do with __config.. is there any possiblity???
 
Top