Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / targetPractice / targetBot / main.c @ 1424

History | View | Annotate | Download (1.04 KB)

1
#include <dragonfly_lib.h>
2
#include <encoders.h>
3

    
4
int main(void)
5
{
6

    
7
        int maxBOM, rangeVal;
8

    
9
        dragonfly_init(ALL_ON);
10
        encoders_init();
11
        
12
        orbs_set_color(GREEN, RED);
13
        delay_ms(500);
14
        orbs_set_color(RED, GREEN);
15
        delay_ms(500);
16
        orbs_set_color(GREEN, GREEN);
17

    
18
        while (1) {
19
                
20
                bom_refresh(BOM_ALL);
21
                delay_ms(100);
22
                maxBOM = bom_get_max();
23
                usb_puti(maxBOM);
24
                usb_putc('\n');
25
                if (maxBOM == 4) {
26
                        motors_off();
27
                        break;
28
                }
29

    
30
                motor_l_set(BACKWARD, 175);
31
                motor_r_set(FORWARD, 175);
32

    
33
        }
34

    
35
        while (1) {
36

    
37
                rangeVal = range_read_distance(IR2);
38
                usb_puti(rangeVal);
39
                usb_putc('\n');
40
                if (rangeVal < 500 && rangeVal > 20) {
41
                        motors_off();
42
                        orbs_set_color(RED, RED);
43
                        break;
44
                }
45

    
46
                motor_l_set(FORWARD, 175);
47
                motor_r_set(FORWARD, 175);
48

    
49
        }
50

    
51
        button2_wait();
52

    
53
        motor_l_set(FORWARD, 175);
54
        motor_r_set(FORWARD, 175);
55

    
56
        while (1) {
57
                if (encoder_get_x(LEFT) > 500) {
58
                        motors_off();
59
                        break;
60
                }
61
        }
62

    
63
        while (1) {
64

    
65
                orbs_set_color(BLUE, GREEN);
66
                delay_ms(500);
67
                orbs_set_color(GREEN, BLUE);
68
                delay_ms(500);
69

    
70
        }
71

    
72
        while (1); /* END HERE */
73

    
74
        return 0;
75
}
76