Project

General

Profile

Revision 1369

updated unit test of motors

View differences:

test_motors.c
1 1
#include <dragonfly_lib.h>
2 2

  
3
#define OFF 	140
4
#define SLOW 	160
5
#define	GO		220
6

  
3 7
int testmotors(void) {
4 8
    //usb_init();
5
    usb_puts("usb turned on\n");
6
    delay_ms(1000);
9
    //usb_puts("usb turned on\n");
10
    
11
	//forward
12
	orb_set_color(RED);
13
	motor1_set(1, OFF);
14
    motor2_set(1, OFF);
15
    delay_ms(3000);
16
    orb_set_color(YELLOW);
17
	motor1_set(1, SLOW);
18
    motor2_set(1, SLOW);
19
    delay_ms(3000);
20
    orb_set_color(GREEN);
21
	motor1_set(1, GO);
22
    motor2_set(1, GO);
23
    delay_ms(3000);
24
	
25
	//backward
26
    orb_set_color(RED);
27
	motor1_set(0, OFF);
28
    motor2_set(0, OFF);
29
    delay_ms(3000);
30
    orb_set_color(YELLOW);
31
	motor1_set(0, SLOW);
32
    motor2_set(0, SLOW);
33
    delay_ms(3000);
34
    orb_set_color(GREEN);
35
	motor1_set(0, GO);
36
    motor2_set(0, GO);
37
    delay_ms(3000);
38
	
39
	//spin
40
	orb_set_color(RED);
41
	motor1_set(1, OFF);
42
    motor2_set(0, OFF);
43
    delay_ms(3000);
44
    orb_set_color(YELLOW);
45
	motor1_set(1, SLOW);
46
    motor2_set(0, SLOW);
47
    delay_ms(3000);
48
    orb_set_color(GREEN);
49
	motor1_set(1, GO);
50
    motor2_set(0, GO);
51
    delay_ms(3000);
52
	
53
	//spin other way
54
	orb_set_color(RED);
55
	motor1_set(0, OFF);
56
    motor2_set(1, OFF);
57
    delay_ms(3000);
58
    orb_set_color(YELLOW);
59
	motor1_set(0, SLOW);
60
    motor2_set(1, SLOW);
61
    delay_ms(3000);
62
    orb_set_color(GREEN);
63
	motor1_set(0, GO);
64
    motor2_set(1, GO);
65
    delay_ms(3000);
66
	//while(1){;}
7 67

  
8
    motor1_set(1, 220);
9
    motor2_set(1, 220);
10
    delay_ms(1000);
11

  
12 68
    return 0;
13 69
}
14 70

  
15 71

  
72
/*test data
73
left >154 forward
74
right >150 forward
75
both >152 backward
76
*/

Also available in: Unified diff