#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
Boy, you are in trouble...
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?
okay can u suggest me then sompe program code for obstacle avoidin robot nd the problem is it cant be readable as it is showing tat the header file for this controller is not right or cant be read
Why suddenly jump to asking for a full program?
You really need to solve your current problems. You can't do anything even if you get a full program, without having enough knowledge to understand what happens. Why? Because any embedded program you find have to be adapted to yuor specific hardware. Embedded isn't like a PC, where you just download a PC program and it will run.
There is no OS that will encapsulate the differences between different processors or the difference with differently connected hardware.
"is it cant be readable as it is showing tat the header file for this controller is not right or cant be read"
So you didn't take the time to investigate?
You didn't manage to leave the IDE for a while and start looking if your machine has such a file somewhere? And you didn't check if such a file (if that is the file you are expected to use for your specific processor) is available from Keil?
Have you even figured out exactly what directories the Keil compiler is scanning when looking for the file?
it is showing when 1 warning my hex file is made but it is showing tat warning header file cant be read i dont noe wats dis i m just a beginner can u help me out or suggest me some program for obstacle avoiding robot
If you are so beginner that you can't even use the Windows Explorer to check if you have a file with that name, then I think you should try something else.
Next thing - when a compiler fails to read a header file, it isn't exactly a nice warning. There is a significant difference between a warning and an error. An error is end-of-game. A warning is a report about a potential problem - it's up to you to check the severity.