Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / forklift_demo / main.cpp @ 2011

History | View | Annotate | Download (1.26 KB)

1 2007 jabinder
#include "Forklift.h"
2 2011 tmullins
#include "twi.h"
3 2007 jabinder
extern "C"
4
{
5
#include <dragonfly_lib.h>
6
}
7
8 2011 tmullins
#define SPD 190 //200
9
#define TURN_TIME 1050 //950
10 2007 jabinder
11
12
using namespace Forklift;
13
14
15
int main()
16
{
17 2011 tmullins
        sei();
18 2007 jabinder
        dragonfly_init(ALL_ON);
19
        orb_init();
20
        forklift_init();
21 2010 tmullins
  orb1_set_color(BLUE);
22
  orb2_set_color(YELLOW);
23 2007 jabinder
        set_height_setpoint(128);
24 2010 tmullins
  orb1_set_color(PURPLE);
25
  orb2_set_color(RED);
26 2011 tmullins
  /*int high = 1;
27
  while(true)
28
  {
29
                set_height_setpoint(high? 100 : 150);
30
                high = !high;
31
                delay_ms(4000);
32
        }*/
33 2007 jabinder
        while(true)
34
        {
35
                while(!button2_read());
36 2010 tmullins
                motor_l_set(BACKWARD, SPD);
37
                motor_r_set(BACKWARD, SPD);
38 2011 tmullins
                delay_ms(800);
39 2010 tmullins
                motor_l_set(BACKWARD, 0);
40
                motor_r_set(BACKWARD, 0);
41
                set_height_setpoint(30);
42 2007 jabinder
                delay_ms(1000);
43 2010 tmullins
                motor_l_set(BACKWARD, SPD);
44
                motor_r_set(BACKWARD, SPD);
45
                delay_ms(200);
46
                set_height_setpoint(230);
47 2011 tmullins
                delay_ms(600);
48
                motor_l_set(BACKWARD, 0);
49
                motor_r_set(BACKWARD, 0);
50
                delay_ms(1200);
51 2010 tmullins
                motor_l_set(BACKWARD, SPD);
52 2007 jabinder
                motor_r_set(FORWARD, SPD);
53 2010 tmullins
                delay_ms(TURN_TIME);
54
                motor_l_set(BACKWARD, SPD);
55 2007 jabinder
                motor_r_set(BACKWARD, SPD);
56 2011 tmullins
                delay_ms(800);
57 2010 tmullins
                motor_l_set(BACKWARD, SPD);
58 2007 jabinder
                motor_r_set(FORWARD, SPD);
59 2010 tmullins
                delay_ms(TURN_TIME);
60
                motor_l_set(BACKWARD, 0);
61
                motor_r_set(BACKWARD, 0);
62 2011 tmullins
                set_height_setpoint(128);
63 2007 jabinder
        }
64 2010 tmullins
}