root / trunk / code / projects / colonet / robot / joystick / simple_slave / slave.c @ 866
History | View | Annotate | Download (1.14 KB)
1 |
#include <dragonfly_lib.h> |
---|---|
2 |
#include <wireless.h> |
3 |
#include "../../../common/colonet_defs.h" |
4 |
|
5 |
|
6 |
|
7 |
int main (void) { |
8 |
dragonfly_init(SERIAL | USB | COMM | ORB | ANALOG | MOTORS | BUZZER); |
9 |
ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0); |
10 |
xbee_init(); |
11 |
orb_set_color(PURPLE); |
12 |
|
13 |
char buf[100]; |
14 |
char c;
|
15 |
while (1) { |
16 |
c = xbee_getc(); |
17 |
orb_set_color(GREEN); |
18 |
sprintf(buf, "got char: %c\n", c);
|
19 |
usb_puts(buf); |
20 |
|
21 |
if (c == 'f') { |
22 |
orb_set_color(GREEN); |
23 |
motor1_set(1, 250); |
24 |
motor2_set(1, 250); |
25 |
} |
26 |
if (c == 'b') { |
27 |
orb_set_color(BLUE); |
28 |
motor1_set(0, 250); |
29 |
motor2_set(0, 250); |
30 |
} |
31 |
if (c == 'l') { |
32 |
orb_set_color(ORANGE); |
33 |
motor1_set(0, 250); |
34 |
motor2_set(1, 250); |
35 |
} |
36 |
if (c == 'r') { |
37 |
orb_set_color(YELLOW); |
38 |
motor1_set(1, 250); |
39 |
motor2_set(0, 250); |
40 |
} |
41 |
if (c == 's') { |
42 |
orb_set_color(RED); |
43 |
motor1_set(0, 0); |
44 |
motor2_set(0, 0); |
45 |
} |
46 |
if (c == 't') { |
47 |
orb_set_color(PURPLE); |
48 |
buzzer_chirp(1000, C5);
|
49 |
} |
50 |
if (c == 'u') { |
51 |
orb_set_color(YELLOW); |
52 |
buzzer_chirp(1000, A4);
|
53 |
} |
54 |
|
55 |
delay_ms(100);
|
56 |
} |
57 |
|
58 |
} |
59 |
|