root / trunk / code / projects / activities_fair_demo / main.c @ 2001
History | View | Annotate | Download (4 KB)
1 |
/*
|
---|---|
2 |
* main.c for activities fair demo
|
3 |
*
|
4 |
* Author: Colony Project, CMU Robotics Club
|
5 |
*/
|
6 |
|
7 |
#include <dragonfly_lib.h> |
8 |
#include "../linefollowing/lineDrive.h" |
9 |
|
10 |
#define LINESPEED 180 |
11 |
#define T 100 |
12 |
#define SPD 190 |
13 |
int main (void) { |
14 |
|
15 |
/* Initialize the dragonfly boards, the xbee, encoders, lineFollowing */
|
16 |
dragonfly_init(ALL_ON); |
17 |
orb_init(); |
18 |
if(button2_read()){
|
19 |
lineDrive_init(); |
20 |
while(true) |
21 |
doDrive(LINESPEED); |
22 |
} else {
|
23 |
buzzer_init(); |
24 |
orb1_set_color(YELLOW); |
25 |
a6(T/2);
|
26 |
orb2_set_color(YELLOW); |
27 |
e7(T*3);
|
28 |
delay_ms(T*3);
|
29 |
while(1){ |
30 |
{ //i==1
|
31 |
motor_l_set(FORWARD, SPD); |
32 |
motor_r_set(BACKWARD, SPD+10);
|
33 |
orb1_set_color(GREEN); |
34 |
e6(T*2);
|
35 |
b5(T); |
36 |
c6(T); |
37 |
orb2_set_color(GREEN); |
38 |
d6(T*2);
|
39 |
orb2_set_color(CYAN); |
40 |
c6(T); |
41 |
|
42 |
motor_l_set(FORWARD, SPD-10);
|
43 |
motor_r_set(FORWARD, SPD-10);;
|
44 |
b5(T); |
45 |
orb1_set_color(CYAN); |
46 |
a5(T*2);
|
47 |
a5(T); |
48 |
c6(T); |
49 |
orb1_set_color(ORANGE); |
50 |
orb2_set_color(ORANGE); |
51 |
e6(T*2);
|
52 |
orb1_set_color(RED); |
53 |
orb2_set_color(RED); |
54 |
d6(T); |
55 |
c6(T); |
56 |
orb1_set_color(LIME); |
57 |
orb2_set_color(LIME); |
58 |
b5(T*3);
|
59 |
c6(T); |
60 |
d6(T*2);
|
61 |
orb1_set_color(BLUE); |
62 |
} |
63 |
|
64 |
{ //i==2
|
65 |
motor_l_set(FORWARD, SPD); |
66 |
motor_r_set(BACKWARD, SPD); |
67 |
e6(T*2);
|
68 |
orb2_set_color(BLUE); |
69 |
c6(T*2);
|
70 |
orb2_set_color(ORB_OFF); |
71 |
a5(T*2);
|
72 |
orb1_set_color(ORB_OFF); |
73 |
a5(T); |
74 |
|
75 |
{ motors_off(); |
76 |
a5(T*1);
|
77 |
delay_ms(T*2);
|
78 |
} |
79 |
motor_l_set(FORWARD, SPD-10);
|
80 |
motor_r_set(FORWARD, SPD-10);
|
81 |
|
82 |
delay_ms(T); |
83 |
orb2_set_color(WHITE); |
84 |
d6(T); |
85 |
delay_ms(T); |
86 |
orb1_set_color(WHITE); |
87 |
f6(T); |
88 |
orb1_set_color(PINK); |
89 |
orb2_set_color(PINK); |
90 |
a6(T); |
91 |
c6(T/2);
|
92 |
c6(T/2);
|
93 |
g6(T); |
94 |
f6(T); |
95 |
orb1_set_color(GREEN); |
96 |
orb2_set_color(GREEN); |
97 |
e6(T*2);
|
98 |
delay_ms(T); |
99 |
orb2_set_color(RED); |
100 |
orb1_set_color(RED); |
101 |
c6(T); |
102 |
e6(T); |
103 |
a5(T/2);
|
104 |
g5(T/2);
|
105 |
|
106 |
d6(T); |
107 |
} |
108 |
{ //i==3
|
109 |
motor_l_set(FORWARD, SPD); |
110 |
motor_r_set(BACKWARD, SPD); |
111 |
c6(T); |
112 |
b5(T*2);
|
113 |
|
114 |
delay_ms(T); |
115 |
orb2_set_color(PURPLE); |
116 |
orb1_set_color(PURPLE); |
117 |
c6(T); |
118 |
d6(T*2);
|
119 |
orb2_set_color(RED); |
120 |
motor_r_set(FORWARD, SPD); |
121 |
e6(T*2);
|
122 |
orb1_set_color(RED); |
123 |
c6(T*2);
|
124 |
orb1_set_color(ORB_OFF); |
125 |
a5(T); |
126 |
a4(T); |
127 |
orb2_set_color(ORB_OFF); |
128 |
a5(T); |
129 |
a4(T); |
130 |
|
131 |
{ |
132 |
motors_off(); |
133 |
delay_ms(T*2);
|
134 |
orb2_set_color(ORANGE); |
135 |
orb1_set_color(ORANGE); |
136 |
e6(T); |
137 |
} |
138 |
motor_l_set(FORWARD, SPD); |
139 |
motor_r_set(FORWARD, SPD); |
140 |
e6(T*3);
|
141 |
orb2_set_color(RED); |
142 |
orb1_set_color(RED); |
143 |
c6(T*3);
|
144 |
} |
145 |
{ //i==4
|
146 |
motor_l_set(FORWARD, SPD); |
147 |
motor_r_set(BACKWARD, SPD); |
148 |
c6(T); |
149 |
orb2_set_color(MAGENTA); |
150 |
orb1_set_color(MAGENTA); |
151 |
d6(T*4);
|
152 |
orb2_set_color(CYAN); |
153 |
orb1_set_color(CYAN); |
154 |
b5(T*2);
|
155 |
|
156 |
motor_r_set(FORWARD, SPD); |
157 |
b5(T*2);
|
158 |
orb2_set_color(PURPLE); |
159 |
orb1_set_color(PURPLE); |
160 |
c6(T*4);
|
161 |
orb2_set_color(PINK); |
162 |
orb1_set_color(PINK); |
163 |
a5(T*4);
|
164 |
orb2_set_color(BLUE); |
165 |
orb1_set_color(GREEN); |
166 |
ab5(T*4);
|
167 |
orb1_set_color(BLUE); |
168 |
orb2_set_color(GREEN); |
169 |
b5(T); |
170 |
} |
171 |
{ //i==5
|
172 |
motor_l_set(FORWARD, SPD); |
173 |
motor_r_set(BACKWARD, SPD); |
174 |
b5(T*2);
|
175 |
delay_ms(T); |
176 |
orb2_set_color(ORANGE); |
177 |
orb1_set_color(ORANGE); |
178 |
e6(T*4);
|
179 |
orb2_set_color(RED); |
180 |
orb1_set_color(RED); |
181 |
|
182 |
motor_r_set(FORWARD, SPD); |
183 |
c6(T*4);
|
184 |
orb2_set_color(MAGENTA); |
185 |
orb1_set_color(MAGENTA); |
186 |
d6(T*4);
|
187 |
orb2_set_color(CYAN); |
188 |
orb1_set_color(CYAN); |
189 |
b5(T*4);
|
190 |
c6(T*2);
|
191 |
orb1_set_color(WHITE); |
192 |
e6(T); |
193 |
} |
194 |
motors_off(); |
195 |
|
196 |
{ //CIRCLE
|
197 |
|
198 |
motor_l_set(FORWARD, SPD); |
199 |
motor_r_set(BACKWARD, SPD); |
200 |
e6(T); |
201 |
orb2_set_color(WHITE); |
202 |
|
203 |
a6(T*4);
|
204 |
|
205 |
} |
206 |
{ //RESET
|
207 |
motor_l_set(FORWARD, SPD+50);
|
208 |
motor_r_set(FORWARD, SPD); |
209 |
|
210 |
orb1_set_color(LIME); |
211 |
orb2_set_color(LIME); |
212 |
ab6(T); |
213 |
orb1_set_color(ORB_OFF); |
214 |
orb2_set_color(ORB_OFF); |
215 |
|
216 |
delay_ms(T*13);
|
217 |
|
218 |
motor_l_set(BACKWARD, SPD); |
219 |
motor_r_set(FORWARD, SPD); |
220 |
delay_ms(T*3);
|
221 |
} |
222 |
|
223 |
motors_off(); |
224 |
delay_ms(T*5);
|
225 |
|
226 |
} |
227 |
} |
228 |
return 0; |
229 |
} |