Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.46 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
    /* initialize components, set wireless channel */
18
    dragonfly_init(ALL_ON);
19
    encoders_init();
20
    lineFollow_init();
21

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

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

    
47
        int barcode = lineFollow(190);
48

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

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

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

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