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

avoider robot

i need help.
i get this source code

#include <at89x51.h>
#include <delay.h>
#define usi P3_2 // ultrasonic in
#define uso P3_3 // ultrasonic out

unsigned char i;
bit x;

at 0x90 sbit md1; // left
at 0x91 sbit me1; //
at 0x92 sbit md2; // right
at 0x93 sbit me2; //

void cek_jarak()
{ TH0 = 0x00;
TL0 = 0x00;
TF0 = 0;
TF1 = 0;
usi = 1;
TR1 = 1;
while(!TF1);
TR1 = 0;
usi = 0;
while(!uso);
TR0 = 1;
while(uso);
TR0 = 0;
}

void perjalanan(bit a, bit b, bit c, bit d)
{me1= a; me2= b; md1= c; md2= d;}

void main()
{ TMOD = 0x21 ;
TCON = 0x00 ;
TH1 = 100;
while(1)
{ cek_jarak();
if(TH0 > 0x00) perjalanan(0,0,1,1);// forward
else
{ perjalanan(0,0,0,0);// backward
for(i=0; i<100; i++)delay(6000);
perjalanan(0,0,x,~x);// turn right/left
for(i=0; i<100; i++)delay(6000);
} x = ~x;
} }

but i cannot compile it.
can anybody help?

Parents
  • Q: 1) What compiler was the source written for?
    A: C Compiler it called microC for 8051

    That's not Keil's compiler, is it?
    Note that this forum is specifically for questions about Keil's products!

    Q: 1) What compiler was the source written for?
    A: i dont understand the question.

    In other words, what compiler are you actually using?

    If the code was written for one compiler, but you're using a different compiler - then you must expect that changes will be necessary due to the differences between the two compilers!

    The operation of adapting code from one compiler to another is callled "porting" - and it is not a novice task!

    Q: 5) Have you looked in the manual what the errors mean?
    A: there's no manual for the errors, thats why i tried to goggling, but zero result

    In that case, the compiler is rubbish and you should throw it away now!
    Good documentation is absolutely essential to a usable compiler!

    Keil document the C51 error messages here: http://www.keil.com/support/man/docs/c51/c51_errors.htm

    i just try to learn about this.

    Actually, the trouble is that you are trying to jump straight in without first having taken the time to learn the basics.

    Here are some reading suggestions:
    http://www.keil.com/books/

Reply
  • Q: 1) What compiler was the source written for?
    A: C Compiler it called microC for 8051

    That's not Keil's compiler, is it?
    Note that this forum is specifically for questions about Keil's products!

    Q: 1) What compiler was the source written for?
    A: i dont understand the question.

    In other words, what compiler are you actually using?

    If the code was written for one compiler, but you're using a different compiler - then you must expect that changes will be necessary due to the differences between the two compilers!

    The operation of adapting code from one compiler to another is callled "porting" - and it is not a novice task!

    Q: 5) Have you looked in the manual what the errors mean?
    A: there's no manual for the errors, thats why i tried to goggling, but zero result

    In that case, the compiler is rubbish and you should throw it away now!
    Good documentation is absolutely essential to a usable compiler!

    Keil document the C51 error messages here: http://www.keil.com/support/man/docs/c51/c51_errors.htm

    i just try to learn about this.

    Actually, the trouble is that you are trying to jump straight in without first having taken the time to learn the basics.

    Here are some reading suggestions:
    http://www.keil.com/books/

Children