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

View differences:

main.cpp
1 1
#include "Forklift.h"
2

  
2
#include "twi.h"
3 3
extern "C"
4 4
{
5 5
#include <dragonfly_lib.h>
6 6
}
7 7

  
8
#define SPD 200
9
#define TURN_TIME 950
8
#define SPD 190 //200
9
#define TURN_TIME 1050 //950
10 10

  
11 11

  
12 12
using namespace Forklift;
......
14 14

  
15 15
int main()
16 16
{
17
	sei();
17 18
	dragonfly_init(ALL_ON);
18 19
	orb_init();
19 20
	forklift_init();
......
22 23
	set_height_setpoint(128);
23 24
  orb1_set_color(PURPLE);
24 25
  orb2_set_color(RED);
26
  /*int high = 1;
27
  while(true)
28
  {
29
		set_height_setpoint(high? 100 : 150);
30
		high = !high;
31
		delay_ms(4000);
32
	}*/
25 33
	while(true)
26 34
	{
27 35
		while(!button2_read());
28 36
		motor_l_set(BACKWARD, SPD);
29 37
		motor_r_set(BACKWARD, SPD);
30
		delay_ms(1500);
38
		delay_ms(800);
31 39
		motor_l_set(BACKWARD, 0);
32 40
		motor_r_set(BACKWARD, 0);
33 41
		set_height_setpoint(30);
......
36 44
		motor_r_set(BACKWARD, SPD);
37 45
		delay_ms(200);
38 46
		set_height_setpoint(230);
39
		delay_ms(1000);
47
		delay_ms(600);
48
		motor_l_set(BACKWARD, 0);
49
		motor_r_set(BACKWARD, 0);
50
		delay_ms(1200);
40 51
		motor_l_set(BACKWARD, SPD);
41 52
		motor_r_set(FORWARD, SPD);
42 53
		delay_ms(TURN_TIME);
43 54
		motor_l_set(BACKWARD, SPD);
44 55
		motor_r_set(BACKWARD, SPD);
45
		delay_ms(1500);
56
		delay_ms(800);
46 57
		motor_l_set(BACKWARD, SPD);
47 58
		motor_r_set(FORWARD, SPD);
48 59
		delay_ms(TURN_TIME);
49 60
		motor_l_set(BACKWARD, 0);
50 61
		motor_r_set(BACKWARD, 0);
51
		set_height_setpoint(130);
62
		set_height_setpoint(128);
52 63
	}
53 64
}

Also available in: Unified diff