Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (2.14 KB)

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

    
4
/* 
5
*  read_line 0 = Sensor 1
6
*  read_line 1 = Sensor 8
7
*  read_line 2 = Sensor 4
8
*  read_line 3 = Sensor 6
9
*  read_line 4 = Sensor 2
10
*  read_line 5 = Sensor 7
11
*  read_line 6 = Sensor 3
12
*  read_line 7 = Sensor 5
13
*/
14

    
15
int main(void)
16
{
17

    
18
        /* initialize components, set wireless channel */
19
        dragonfly_init(ALL_ON);
20
        lineFollow_init();
21
        int barCode;
22
        while(1)
23
        {
24
                usb_puti(read_line(0));
25
                usb_putc('\t');
26
                usb_puti(read_line(4));
27
                usb_putc('\t');
28
                usb_puti(read_line(6));
29
                usb_putc('\t');
30
                usb_puti(read_line(2));
31
                usb_putc('\t');
32
                usb_puti(read_line(7));
33
                usb_putc('\t');
34
                usb_puti(read_line(3));
35
                usb_putc('\t');
36
                usb_puti(read_line(5));
37
                usb_putc('\t');
38
                usb_puti(read_line(1));
39
                usb_putc('\t');
40
                usb_putc(13);
41

    
42
        /*        
43

44
                for(int q=0; q<500; q++)
45
                        barCode = lineFollow(200);
46
                while(mergeLeft());
47
                for(int q=0; q<1000; q++)lineFollow(200);
48
                
49
                continue;
50
                if(barCode==-25)while(turnRight());
51
                continue;
52
                if(barCode != -2 && barCode != LINELOST)
53
                {
54
                        usb_puti(barCode);
55
                        usb_putc('\n');
56
                }
57
*/
58

    
59

    
60

    
61
/*                
62

63
                switch (barCode)
64
                {        
65

66
                
67
                        case 0: orb_set_color(RED); break;
68
                        case 1: orb_set_color(ORANGE); break;
69
                        case 2: orb_set_color(YELLOW); break;
70
                        case 3: orb_set_color(LIME); break;
71
                        case 4: orb_set_color(GREEN); break;
72
                        case 5: orb_set_color(CYAN); break;
73
                        case 6: orb_set_color(BLUE); break;
74
                        case 7: orb_set_color(PINK); break;
75
                        case 8: orb_set_color(PURPLE); break;
76
                        case 9: orb_set_color(MAGENTA); break;
77
                        default: orb_set_color(WHITE); break;
78
        
79
                        case 0:
80
                                straight();
81
                                turnRight();
82
                                break;
83
                        case 2:
84
                                straight();
85
                                break;
86
                        case 3:
87
                                straight();
88
                                turnLeft();
89
                                break;
90
                
91
                }
92
*/        
93
        }
94
        return 0;
95
}
96
void right()
97
{
98
motor_r_set(BACKWARD, 200);
99
motor_l_set(FORWARD, 200);
100
delay_ms(400);
101
}
102

    
103

    
104
void straight()
105
{
106
motor_r_set(FORWARD, 210);
107
motor_l_set(FORWARD, 210);
108
delay_ms(200);
109
move(0,0);
110
delay_ms(2000);
111
}
112

    
113
void left()
114
{
115
motor_l_set(BACKWARD, 200);
116
motor_r_set(FORWARD, 200);
117
delay_ms(400);
118
}