Project

General

Profile

Statistics
| Revision:

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

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

    
19
    /* initialize components, set wireless channel */
20
    dragonfly_init(ALL_ON);
21
    lineFollow_init();
22

    
23
    /*while(1)
24
    {
25
        usb_puti(read_line(0));
26
        usb_putc('\t');
27
        usb_puti(read_line(1));
28
        usb_putc('\t');
29
        usb_puti(read_line(2));
30
        usb_putc('\t');
31
        usb_puti(read_line(3));
32
        usb_putc('\t');
33
        usb_puti(read_line(4));
34
        usb_putc('\t');
35
        usb_puti(read_line(5));
36
        usb_putc('\t');
37
        usb_puti(read_line(6));
38
        usb_putc('\t');
39
        usb_puti(read_line(7));
40
        usb_putc('\t');
41
        usb_putc(13);
42
    }*/
43

    
44
    int barCode;
45
    while(1)
46
    {
47

    
48
        int barcode = lineFollow(200);
49

    
50
        if(barcode != NOBARCODE)
51
        {
52
            usb_puti(barcode);
53
            usb_puts("\n");
54
        }
55

    
56
    }
57
    return 0;
58
}
59
void right()
60
{
61
    motor_r_set(BACKWARD, 200);
62
    motor_l_set(FORWARD, 200);
63
    delay_ms(400);
64
}
65

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

    
75
void left()
76
{
77
    motor_l_set(BACKWARD, 200);
78
    motor_r_set(FORWARD, 200);
79
    delay_ms(400);
80
}