Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.43 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 1851 djacobs
                //for(int q=0; q<500; q++)
16
                        barCode = lineFollow(200);
17
                if(barCode==-25)while(turnLeft());
18
                continue;
19 1845 dgurjar
                if(barCode != -2 && barCode != LINELOST)
20
                {
21
                        usb_puti(barCode);
22
                        usb_putc('\n');
23
                }
24
/*
25

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

54 1842 djacobs
                }
55 1845 dgurjar
*/
56 1842 djacobs
        }
57 1836 dgurjar
        return 0;
58
}
59 1851 djacobs
void right()
60 1842 djacobs
{
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 1851 djacobs
void left()
77 1842 djacobs
{
78
motor_l_set(BACKWARD, 200);
79
motor_r_set(FORWARD, 200);
80
delay_ms(400);
81
}