forked from acornejo/kilobot-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-movement.c
41 lines (34 loc) · 876 Bytes
/
simple-movement.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <kilolib.h>
void setup() { }
void loop() {
// Turn led green
set_color(RGB(0,1,0));
// spinup motors
spinup_motors();
// move straight for 2 seconds (2000ms)
set_motors(kilo_straight_left, kilo_straight_right);
delay(2000);
// Turn led red
set_color(RGB(1,0,0));
// spinup for 15ms to overcome frction
spinup_motors();
// turn left for 2 seconds (2000ms)
set_motors(kilo_turn_left, 0);
delay(2000);
// Turn led blue
set_color(RGB(0,0,1));
// spinup for 15ms to overcome frction
spinup_motors();
// turn right for 2 seconds (200 ms)
set_motors(0, kilo_turn_right);
delay(2000);
// Turn off led and stop for half sec (500ms)
set_color(RGB(0,0,0));
set_motors(0,0);
delay(500);
}
int main() {
kilo_init();
kilo_start(setup, loop);
return 0;
}