HIGHLIFE
March 12th, 2008, 04:41 AM
Hey guys I was playing around with BrickOS and had a problem with this code:
#include <config.h>
#include <dmotor.h>
#include <dsensor.h>
int main()
{
while (1)
{
motor_a_dir(fwd);
motor_c_dir(fwd);
motor_a_speed(255);
motor_c_speed(255);
if (TOUCH_1 == 1)
{
motor_a_dir(rev);
motor_a_speed(0);
}
else
{
motor_a_dir(fwd);
motor_a_speed(255);
}
}
return 0;
}
When I press the touch sensor the motor just jitters in the reverse direction rather than driving backwards at full speed. What am I doing wrong here?
#include <config.h>
#include <dmotor.h>
#include <dsensor.h>
int main()
{
while (1)
{
motor_a_dir(fwd);
motor_c_dir(fwd);
motor_a_speed(255);
motor_c_speed(255);
if (TOUCH_1 == 1)
{
motor_a_dir(rev);
motor_a_speed(0);
}
else
{
motor_a_dir(fwd);
motor_a_speed(255);
}
}
return 0;
}
When I press the touch sensor the motor just jitters in the reverse direction rather than driving backwards at full speed. What am I doing wrong here?