Revision 754
added a comment
main.c | ||
---|---|---|
1 |
|
|
2 |
/* encoders_test: this behavior uses the encoders to move a given |
|
3 |
* distance, specified by GO where GO/1024 is the number of wheel |
|
4 |
* rotations. |
|
5 |
* It first calibrates the motors by finding the minimum reading |
|
6 |
* it can use to move them. |
|
7 |
*/ |
|
8 |
|
|
1 | 9 |
#include <dragonfly_lib.h> |
2 | 10 |
//#define usb_puti(x) x |
3 | 11 |
|
4 |
#define GO 1024
|
|
12 |
#define GO 2048
|
|
5 | 13 |
#define K 1 |
6 | 14 |
|
7 | 15 |
#define ABS(x) ((x>0)?x:-x) |
... | ... | |
16 | 24 |
|
17 | 25 |
encoders_init(); |
18 | 26 |
|
19 |
while(l<4){
|
|
27 |
while(l<10){
|
|
20 | 28 |
l=encoder_get_dx(LEFT); |
21 | 29 |
motor1_set(FORWARD,++lmin); |
22 | 30 |
delay_ms(1); |
23 | 31 |
} |
24 | 32 |
motor1_set(FORWARD,0); |
25 | 33 |
|
26 |
while(r<4){
|
|
34 |
while(r<10){
|
|
27 | 35 |
r=encoder_get_dx(RIGHT); |
28 | 36 |
motor2_set(FORWARD,++rmin); |
29 | 37 |
delay_ms(1); |
Also available in: Unified diff