Project

General

Profile

Revision 1942

Updated barcode code to use the new line sensor, and to work better.

View differences:

main.c
2 2
#include <lineFollow.h>
3 3

  
4 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
*/
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 14

  
15 15
int main(void)
16 16
{
17 17

  
18
	/* initialize components, set wireless channel */
19
	dragonfly_init(ALL_ON);
20
	lineFollow_init();
21
	int barCode;
22
	while(1)
23
	{
24
		
25
		lineFollow(200);
26 18

  
19
    /* initialize components, set wireless channel */
20
    dragonfly_init(ALL_ON);
21
    lineFollow_init();
27 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
    }*/
28 43

  
29
	
30
	}
31
	return 0;
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;
32 58
}
33 59
void right()
34 60
{
35
motor_r_set(BACKWARD, 200);
36
motor_l_set(FORWARD, 200);
37
delay_ms(400);
61
    motor_r_set(BACKWARD, 200);
62
    motor_l_set(FORWARD, 200);
63
    delay_ms(400);
38 64
}
39 65

  
40 66
void straight()
41 67
{
42
motor_r_set(FORWARD, 210);
43
motor_l_set(FORWARD, 210);
44
delay_ms(200);
45
move(0,0);
46
delay_ms(2000);
68
    motor_r_set(FORWARD, 210);
69
    motor_l_set(FORWARD, 210);
70
    delay_ms(200);
71
    move(0,0);
72
    delay_ms(2000);
47 73
}
48 74

  
49 75
void left()
50 76
{
51
motor_l_set(BACKWARD, 200);
52
motor_r_set(FORWARD, 200);
53
delay_ms(400);
77
    motor_l_set(BACKWARD, 200);
78
    motor_r_set(FORWARD, 200);
79
    delay_ms(400);
54 80
}

Also available in: Unified diff