Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.51 KB)

1 16 bcoltin
#include <dragonfly_lib.h>
2 1841 djacobs
#include <lineFollow.h>
3 16 bcoltin
4 1836 dgurjar
5 1838 dgurjar
6 857 bcoltin
int main(void)
7
{
8 1419 jsexton
9 967 alevkoy
        /* initialize components, set wireless channel */
10 857 bcoltin
        dragonfly_init(ALL_ON);
11 1841 djacobs
        lineFollow_init();
12 1842 djacobs
        int barCode;
13 1841 djacobs
        while(1)
14 1842 djacobs
        {
15 1854 djacobs
16
17
                for(int q=0; q<500; q++)
18 1851 djacobs
                        barCode = lineFollow(200);
19 1854 djacobs
                while(mergeLeft());
20
                for(int q=0; q<1000; q++)lineFollow(200);
21
22
                continue;
23 1853 djacobs
                if(barCode==-25)while(turnRight());
24 1851 djacobs
                continue;
25 1845 dgurjar
                if(barCode != -2 && barCode != LINELOST)
26
                {
27
                        usb_puti(barCode);
28
                        usb_putc('\n');
29
                }
30
/*
31

32 1842 djacobs
                switch (barCode)
33 1845 dgurjar
                {
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 1842 djacobs
                        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 1845 dgurjar

60 1842 djacobs
                }
61 1845 dgurjar
*/
62 1842 djacobs
        }
63 1836 dgurjar
        return 0;
64
}
65 1851 djacobs
void right()
66 1842 djacobs
{
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 1851 djacobs
void left()
83 1842 djacobs
{
84
motor_l_set(BACKWARD, 200);
85
motor_r_set(FORWARD, 200);
86
delay_ms(400);
87
}