Revision 2010 trunk/code/projects/forklift_demo/main.cpp

View differences:

main.cpp
6 6
}
7 7

  
8 8
#define SPD 200
9
#define TURN_TIME 950
9 10

  
10 11

  
11 12
using namespace Forklift;
......
16 17
	dragonfly_init(ALL_ON);
17 18
	orb_init();
18 19
	forklift_init();
20
  orb1_set_color(BLUE);
21
  orb2_set_color(YELLOW);
19 22
	set_height_setpoint(128);
23
  orb1_set_color(PURPLE);
24
  orb2_set_color(RED);
20 25
	while(true)
21 26
	{
22 27
		while(!button2_read());
23
		motor_l_set(FORWARD, SPD);
24
		motor_r_set(FORWARD, SPD);
28
		motor_l_set(BACKWARD, SPD);
29
		motor_r_set(BACKWARD, SPD);
25 30
		delay_ms(1500);
26
		motor_l_set(FORWARD, 0);
27
		motor_r_set(FORWARD, 0);
28
		set_height_setpoint(0);
31
		motor_l_set(BACKWARD, 0);
32
		motor_r_set(BACKWARD, 0);
33
		set_height_setpoint(30);
29 34
		delay_ms(1000);
30
		motor_l_set(FORWARD, SPD);
35
		motor_l_set(BACKWARD, SPD);
36
		motor_r_set(BACKWARD, SPD);
37
		delay_ms(200);
38
		set_height_setpoint(230);
39
		delay_ms(1000);
40
		motor_l_set(BACKWARD, SPD);
31 41
		motor_r_set(FORWARD, SPD);
32
		delay_ms(200);
33
		set_height_setpoint(255);
34
		motor_l_set(FORWARD, SPD);
42
		delay_ms(TURN_TIME);
43
		motor_l_set(BACKWARD, SPD);
35 44
		motor_r_set(BACKWARD, SPD);
36
		delay_ms(500);
37
		motor_l_set(FORWARD, SPD);
45
		delay_ms(1500);
46
		motor_l_set(BACKWARD, SPD);
38 47
		motor_r_set(FORWARD, SPD);
39
		delay_ms(1500);
40
		motor_l_set(FORWARD, SPD);
41
		motor_r_set(BACKWARD, SPD);
42
		delay_ms(500);
43
		motor_l_set(FORWARD, 0);
44
		motor_r_set(FORWARD, 0);
45
		set_height_setpoint(128);
48
		delay_ms(TURN_TIME);
49
		motor_l_set(BACKWARD, 0);
50
		motor_r_set(BACKWARD, 0);
51
		set_height_setpoint(130);
46 52
	}
47
}
53
}

Also available in: Unified diff