Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.36 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
                barCode = lineFollow();
16
                if(barCode != -2 && barCode != LINELOST)
17
                {
18
                        usb_puti(barCode);
19
                        usb_putc('\n');
20
                }
21
/*                
22

23
                switch (barCode)
24
                {        
25

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

    
63

    
64
void straight()
65
{
66
motor_r_set(FORWARD, 210);
67
motor_l_set(FORWARD, 210);
68
delay_ms(200);
69
move(0,0);
70
delay_ms(2000);
71
}
72

    
73
void turnLeft()
74
{
75
motor_l_set(BACKWARD, 200);
76
motor_r_set(FORWARD, 200);
77
delay_ms(400);
78
}