Author Topic: pic did not receive any input  (Read 1680 times)

0 Members and 1 Guest are viewing this topic.

Offline r0b0t1cTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
pic did not receive any input
« on: March 03, 2013, 01:13:37 AM »
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

Code: [Select]
#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?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: pic did not receive any input
« Reply #1 on: March 03, 2013, 09:42:15 AM »
Yes, what are all of the CONFIG bits set to?
With HiTech C it is best to put the CONFIG in the code (so we can see what they are and when you try using this code latter you'll know what was used).

Have you tried just blinking an LED to see it the PIC is running?
Do you have 0.1uF de-coupling caps across Vdd to Vss close to the PICs pins?

Did you step/run the code in MPLAB Simulator using the Stimulus for pin inputs?

 


Get Your Ad Here

data_list