Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / linefollowing / main.c @ 1851

History | View | Annotate | Download (1.43 KB)

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

    
4

    
5

    
6
int main(void)
7
{
8

    
9
        /* initialize components, set wireless channel */
10
        dragonfly_init(ALL_ON);
11
        lineFollow_init();
12
        int barCode;
13
        while(1)
14
        {
15
                //for(int q=0; q<500; q++)
16
                        barCode = lineFollow(200);
17
                if(barCode==-25)while(turnLeft());
18
                continue;
19
                if(barCode != -2 && barCode != LINELOST)
20
                {
21
                        usb_puti(barCode);
22
                        usb_putc('\n');
23
                }
24
/*                
25

26
                switch (barCode)
27
                {        
28

29
                
30
                        case 0: orb_set_color(RED); break;
31
                        case 1: orb_set_color(ORANGE); break;
32
                        case 2: orb_set_color(YELLOW); break;
33
                        case 3: orb_set_color(LIME); break;
34
                        case 4: orb_set_color(GREEN); break;
35
                        case 5: orb_set_color(CYAN); break;
36
                        case 6: orb_set_color(BLUE); break;
37
                        case 7: orb_set_color(PINK); break;
38
                        case 8: orb_set_color(PURPLE); break;
39
                        case 9: orb_set_color(MAGENTA); break;
40
                        default: orb_set_color(WHITE); break;
41
        
42
                        case 0:
43
                                straight();
44
                                turnRight();
45
                                break;
46
                        case 2:
47
                                straight();
48
                                break;
49
                        case 3:
50
                                straight();
51
                                turnLeft();
52
                                break;
53
                
54
                }
55
*/        
56
        }
57
        return 0;
58
}
59
void right()
60
{
61
motor_r_set(BACKWARD, 200);
62
motor_l_set(FORWARD, 200);
63
delay_ms(400);
64
}
65

    
66

    
67
void straight()
68
{
69
motor_r_set(FORWARD, 210);
70
motor_l_set(FORWARD, 210);
71
delay_ms(200);
72
move(0,0);
73
delay_ms(2000);
74
}
75

    
76
void left()
77
{
78
motor_l_set(BACKWARD, 200);
79
motor_r_set(FORWARD, 200);
80
delay_ms(400);
81
}