Project

General

Profile

Revision 1842

Added by Dan Jacobs over 13 years ago

Some barcode code

View differences:

main.c
9 9
	/* initialize components, set wireless channel */
10 10
	dragonfly_init(ALL_ON);
11 11
	lineFollow_init();
12
	int barCode;
12 13
	while(1)
13
		lineFollow();
14

  
14
	{
15
		barCode = lineFollow();
16
		switch (barCode)
17
		{
18
			case 0:
19
				straight();
20
				turnRight();
21
				break;
22
                        case 2:
23
	                        straight();
24
        	                break;
25
                        case 3:
26
	                        straight();
27
				turnLeft();
28
        	                break;
29
		}
30
	}
15 31
	return 0;
16 32
}
33
void turnRight()
34
{
35
motor_r_set(BACKWARD, 200);
36
motor_l_set(FORWARD, 200);
37
delay_ms(400);
38
}
39

  
40

  
41
void straight()
42
{
43
motor_r_set(FORWARD, 210);
44
motor_l_set(FORWARD, 210);
45
delay_ms(200);
46
move(0,0);
47
delay_ms(2000);
48
}
49

  
50
void turnLeft()
51
{
52
motor_l_set(BACKWARD, 200);
53
motor_r_set(FORWARD, 200);
54
delay_ms(400);
55
}

Also available in: Unified diff