Project

General

Profile

Statistics
| Revision:

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

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
    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
    while(1)
44
    {
45
        int barcode = lineFollow(190);
46

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

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

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

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