forked from SSR-Harvard/kilobotics-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_movement.c
46 lines (39 loc) · 959 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
42
43
44
45
46
#include <kilolib.h>
void setup()
{
}
void loop()
{
// Set the LED green.
set_color(RGB(0, 1, 0));
// Spinup the motors to overcome friction.
spinup_motors();
// Move straight for 2 seconds (2000 ms).
set_motors(kilo_straight_left, kilo_straight_right);
delay(2000);
// Set the LED red.
set_color(RGB(1, 0, 0));
// Spinup the motors to overcome friction.
spinup_motors();
// Turn left for 2 seconds (2000 ms).
set_motors(kilo_turn_left, 0);
delay(2000);
// Set the LED blue.
set_color(RGB(0, 0, 1));
// Spinup the motors to overcome friction.
spinup_motors();
// Turn right for 2 seconds (2000 ms).
set_motors(0, kilo_turn_right);
delay(2000);
// Set the LED off.
set_color(RGB(0, 0, 0));
// Stop for half a second (500 ms).
set_motors(0, 0);
delay(500);
}
int main()
{
kilo_init();
kilo_start(setup, loop);
return 0;
}