Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.42 KB)

1 16 bcoltin
#include <dragonfly_lib.h>
2 1841 djacobs
#include <lineFollow.h>
3 16 bcoltin
4 1923 pdeo
/*
5 1942 azirbel
 *  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 1836 dgurjar
15 857 bcoltin
int main(void)
16
{
17 1419 jsexton
18 1922 azirbel
19 1942 azirbel
    /* initialize components, set wireless channel */
20
    dragonfly_init(ALL_ON);
21
    lineFollow_init();
22 1922 azirbel
23 1942 azirbel
    /*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 1922 azirbel
44 1942 azirbel
    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 1836 dgurjar
}
59 1851 djacobs
void right()
60 1842 djacobs
{
61 1942 azirbel
    motor_r_set(BACKWARD, 200);
62
    motor_l_set(FORWARD, 200);
63
    delay_ms(400);
64 1842 djacobs
}
65
66
void straight()
67
{
68 1942 azirbel
    motor_r_set(FORWARD, 210);
69
    motor_l_set(FORWARD, 210);
70
    delay_ms(200);
71
    move(0,0);
72
    delay_ms(2000);
73 1842 djacobs
}
74
75 1851 djacobs
void left()
76 1842 djacobs
{
77 1942 azirbel
    motor_l_set(BACKWARD, 200);
78
    motor_r_set(FORWARD, 200);
79
    delay_ms(400);
80 1842 djacobs
}