Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.51 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
                
16

    
17
                for(int q=0; q<500; q++)
18
                        barCode = lineFollow(200);
19
                while(mergeLeft());
20
                for(int q=0; q<1000; q++)lineFollow(200);
21
                
22
                continue;
23
                if(barCode==-25)while(turnRight());
24
                continue;
25
                if(barCode != -2 && barCode != LINELOST)
26
                {
27
                        usb_puti(barCode);
28
                        usb_putc('\n');
29
                }
30
/*                
31

32
                switch (barCode)
33
                {        
34

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

    
72

    
73
void straight()
74
{
75
motor_r_set(FORWARD, 210);
76
motor_l_set(FORWARD, 210);
77
delay_ms(200);
78
move(0,0);
79
delay_ms(2000);
80
}
81

    
82
void left()
83
{
84
motor_l_set(BACKWARD, 200);
85
motor_r_set(FORWARD, 200);
86
delay_ms(400);
87
}