This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PROBLEM IN PROGRAMMING FOR MICROCONTROLLER

#include<p89v51rd2.h>

#define forward 0x05; //0000 01 01 both motors in forward
#define reverse 0x0a; //0000 10 10 both motors in reverse
#define leftturn 0x06; //0000 01 10 left motor =backwards,
//right motor=forward
#define rightturn 0x09; //0000 10 01 left motor=forward
//right motor=backwards
#define obst P2

void main()
{ int P1,P2;
P1=0xff; //intialize PORT1 as input(sensors)
P2=0x00; //intialize PORT2 as output(motors)

if(obst==0) //Check if sensor has detected an obstacle
{ P2=reverse;
P2=rightturn;
} else
{ P2=forward; //else go forward
}

} THIS IS MY C CODE FOR OBSTACLE AVOIDING ROBOT BUT WHEN USING KEIL I CLICK ON BULIT TARGET IT IS SHOWING 1 WARNING THAT p89v51rd2.h CANT BE READ . PLZ GIVE ME ANSWER I HAV TO SUB,IT MY PROJECT AFTER 2 DAYS

Parents
  • void main() {
        int P1,P2;
        P1=0xff; //intialize PORT1 as input(sensors)
        P2=0x00; //intialize PORT2 as output(motors)
        ...
    

    What makes you think that two local variables P1 and P2 will have association with real ports?

    What make you think that 0xff makes a port as input and 0x00 makes it an output? By the way - what is your definition of motor state for 0x00? What is your definition of motor state for 0xff? Both states are important - one state is the reset state of the processor and one is what you make it to at start of your program.

    If a file can't be read, the questions are:
    - do you have such file?
    - is it readable?
    - is it in a directory where the compiler will look for it?

Reply
  • void main() {
        int P1,P2;
        P1=0xff; //intialize PORT1 as input(sensors)
        P2=0x00; //intialize PORT2 as output(motors)
        ...
    

    What makes you think that two local variables P1 and P2 will have association with real ports?

    What make you think that 0xff makes a port as input and 0x00 makes it an output? By the way - what is your definition of motor state for 0x00? What is your definition of motor state for 0xff? Both states are important - one state is the reset state of the processor and one is what you make it to at start of your program.

    If a file can't be read, the questions are:
    - do you have such file?
    - is it readable?
    - is it in a directory where the compiler will look for it?

Children