Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.44 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
    lineFollow_init();
20

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

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

    
46
        int barcode = lineFollow(170);
47

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

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

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

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