root / trunk / code / projects / forklift_demo / main.cpp @ 2011
History | View | Annotate | Download (1.26 KB)
1 |
#include "Forklift.h" |
---|---|
2 |
#include "twi.h" |
3 |
extern "C" |
4 |
{ |
5 |
#include <dragonfly_lib.h> |
6 |
} |
7 |
|
8 |
#define SPD 190 //200 |
9 |
#define TURN_TIME 1050 //950 |
10 |
|
11 |
|
12 |
using namespace Forklift; |
13 |
|
14 |
|
15 |
int main()
|
16 |
{ |
17 |
sei(); |
18 |
dragonfly_init(ALL_ON); |
19 |
orb_init(); |
20 |
forklift_init(); |
21 |
orb1_set_color(BLUE); |
22 |
orb2_set_color(YELLOW); |
23 |
set_height_setpoint(128);
|
24 |
orb1_set_color(PURPLE); |
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 |
}*/
|
33 |
while(true) |
34 |
{ |
35 |
while(!button2_read());
|
36 |
motor_l_set(BACKWARD, SPD); |
37 |
motor_r_set(BACKWARD, SPD); |
38 |
delay_ms(800);
|
39 |
motor_l_set(BACKWARD, 0);
|
40 |
motor_r_set(BACKWARD, 0);
|
41 |
set_height_setpoint(30);
|
42 |
delay_ms(1000);
|
43 |
motor_l_set(BACKWARD, SPD); |
44 |
motor_r_set(BACKWARD, SPD); |
45 |
delay_ms(200);
|
46 |
set_height_setpoint(230);
|
47 |
delay_ms(600);
|
48 |
motor_l_set(BACKWARD, 0);
|
49 |
motor_r_set(BACKWARD, 0);
|
50 |
delay_ms(1200);
|
51 |
motor_l_set(BACKWARD, SPD); |
52 |
motor_r_set(FORWARD, SPD); |
53 |
delay_ms(TURN_TIME); |
54 |
motor_l_set(BACKWARD, SPD); |
55 |
motor_r_set(BACKWARD, SPD); |
56 |
delay_ms(800);
|
57 |
motor_l_set(BACKWARD, SPD); |
58 |
motor_r_set(FORWARD, SPD); |
59 |
delay_ms(TURN_TIME); |
60 |
motor_l_set(BACKWARD, 0);
|
61 |
motor_r_set(BACKWARD, 0);
|
62 |
set_height_setpoint(128);
|
63 |
} |
64 |
} |