Пример #1
0
static void follow_line() {
  int dir=0;
  
  
  while (!shutdown_requested()) {
    motor_a_speed(NORMAL_SPEED);
    motor_c_speed(NORMAL_SPEED);
    motor_a_dir(fwd);
    motor_c_dir(fwd);
    
    if (wait_event(bright_found,BRIGHT_THRESH) != 0)
    {    
	    if(dir==0)
  	    motor_a_dir(rev);
	    else
  	    motor_c_dir(rev);
#ifdef STRAIGHT_LINE
    		dir=!dir;
#endif
        
	    motor_a_speed(TURN_SPEED);
  	  motor_c_speed(TURN_SPEED);
    
    	wait_event(dark_found,DARK_THRESH);
    }
  }
}
Пример #2
0
int main(int argc, char **argv)
{
  /* start the motor */
  cls();
  cputs("speed");
  msleep(500);
  cputs("150");

  motor_a_dir(fwd);
  motor_c_dir(fwd);
  motor_a_speed(150);
  motor_c_speed(150);

  msleep(2000);
  cls();
  motor_a_dir(off);
  motor_c_dir(off);

  msleep(2000);

  cputs("speed");
  msleep(500);
  cputs("100");

  motor_a_dir(fwd);
  motor_c_dir(fwd);
  motor_a_speed(100-l

  motor_c_speed(100);

  msleep(2000);
  cls();
  motor_a_dir(off);
  motor_c_dir(off);

  cputs("speed");
  msleep(500);
  cputs("75");


  msleep(2000);

  motor_a_dir(fwd);
  motor_c_dir(fwd);
  motor_a_speed(75);
  motor_c_speed(75);

  return 0;
}
Пример #3
0
void hard_left()
{
  motor_a_dir(fwd);
  motor_c_dir(rev);
  motor_a_speed(MAX_SPEED);
  motor_c_speed(MAX_SPEED);
  msleep(100*TURN_MULTIPLIER);
}
Пример #4
0
void soft_right()
{
  motor_a_dir(fwd);
  motor_c_dir(fwd);
  motor_a_speed(MAX_SPEED/2);
  motor_c_speed(MAX_SPEED);
  msleep(75*TURN_MULTIPLIER);
}
Пример #5
0
static void locate_line() {
  motor_a_speed(NORMAL_SPEED);
  motor_c_speed(NORMAL_SPEED);
  motor_a_dir(fwd);
  motor_c_dir(fwd);
  
  wait_event(dark_found,DARK_THRESH);
}
Пример #6
0
//! shutdown motors
//
void dm_shutdown(void) {
  motor_a_dir(off);			// initialize driver data
  motor_b_dir(off);
  motor_c_dir(off);

  motor_a_speed(MAX_SPEED);
  motor_b_speed(MAX_SPEED);
  motor_c_speed(MAX_SPEED);

  motor_controller=0x00;		// shutdown hardware
}
Пример #7
0
void stop_motors()
{
  motor_a_speed(0);
  motor_c_speed(0);
  motor_a_dir(brake);
  motor_c_dir(brake);

  /*to conserve batteries*/
  msleep(500);
  motor_a_dir(off);
  motor_c_dir(off);
}
void moveForward(int duration) {
	
	motor_a_dir(fwd);
	motor_c_dir(fwd);

	motor_a_speed (255);
	motor_c_speed (255);

	if (duration > 0) {
		delay(duration*10);
		motor_a_dir(brake);
		motor_c_dir(brake);
	}

}
void moveBackward(int duration) {
	

	motor_a_dir(rev);
	motor_c_dir(rev);

	motor_a_speed (255);
	motor_c_speed (255);

	if (duration > 0) {
		delay(duration*10);
		motor_a_dir(brake);
		motor_c_dir(brake);
	}

}
void moveRotate(int deg) {

	motor_a_dir(brake);
	motor_a_dir(brake);
	motor_a_speed (255);
	motor_c_speed (255);


	if (deg == 0) return;

	if (deg > 0) {
		motor_a_dir(fwd);
		motor_c_dir(rev);
	}
	if (deg < 0) {
		motor_a_dir(rev);
		motor_c_dir(fwd);
	}

	wait(deg*ms_per_deg);

}
Пример #11
0
void run_motors()
{
  motor_a_speed(MAX_SPEED);
  motor_c_speed(MAX_SPEED);
}