r0b0t1c
Newbie level 4
- Joined
- Jan 28, 2013
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,330
hi. im using PIC16F877a to make a line following robot.
im programming using C language.
it run with no problem when i simulate it using Proteus.
the problem is, when i flash it into PIC, nothing happen.
the PIC is like not responding when there is input.
for example, when i give input '1' to PORTC RC0,
i want the PIC to send the output '1' to PORTB RB0, something like that.
here is my program
do i need to include any header file or configuration?
im programming using C language.
it run with no problem when i simulate it using Proteus.
the problem is, when i flash it into PIC, nothing happen.
the PIC is like not responding when there is input.
for example, when i give input '1' to PORTC RC0,
i want the PIC to send the output '1' to PORTB RB0, something like that.
here is my program
Code:
#include <htc.h>
int main(void) {
TRISB = 0X00; //PortB as output
TRISC = 0XFF; //PortC as input
while(1)
{
//stop
if(PORTC == 0x00 || PORTC == 0x09 || PORTC == 0x0B || PORTC == 0x0D)
{ PORTB = 0x00;
}
//straight
if(PORTC == 0x60 || PORTC == 0xF0)
{ PORTB = 0x05;
}
//right
if(PORTC == 0x80 || PORTC == 0x40)
{ PORTB = 0x01;
}
//left
if(PORTC == 0x10 || PORTC == 0x20)
{ PORTB = 0x04;
}
//sharp left
if(PORTC == 0xC0 || PORTC == 0xA0 || PORTC == 0xE0)
{ PORTB = 0x9;
}
//sharp right
if(PORTC == 0x30 || PORTC == 0x70 || PORTC == 0x50)
{ PORTB = 0x6;
}
}
return 0;
}
do i need to include any header file or configuration?