how to give if condition in c in 8051

Actually i m using adc0804 as input to port 1 and and i want to drive motor to another port according to adc input. But the problem is how to give condition in c
Suppose that i have adc output 11001100, and i want to rotate motor to particular angle then i m giving conditio as folows:

if(P1==0xCC)
{
   mmotor1();
}


In this i am not getting motor movement. Plzzz tell me the right if condition.

Parents
  • It ain't that easy.

    You have to open the books and do some studying.

    The motor isn't magically going to "jump" to a new angle. If it's a stepper motor, you would normally have to generate a lot of steps to change it from say 10 degrees to 27 degrees. And you need to keep track of time length of these pulses etc.

    So you must figure out which direction to rotate. And how long to rotate. And what steps are needed to get that motor to do such length of rotation. And at what speed it can do that. And during that time, you may still have to look at your input sensor and maybe get a new direction to go.

    Good luck.

Reply
  • It ain't that easy.

    You have to open the books and do some studying.

    The motor isn't magically going to "jump" to a new angle. If it's a stepper motor, you would normally have to generate a lot of steps to change it from say 10 degrees to 27 degrees. And you need to keep track of time length of these pulses etc.

    So you must figure out which direction to rotate. And how long to rotate. And what steps are needed to get that motor to do such length of rotation. And at what speed it can do that. And during that time, you may still have to look at your input sensor and maybe get a new direction to go.

    Good luck.

Children
More questions in this forum