Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / test / testrangefinders.c @ 827

History | View | Annotate | Download (917 Bytes)

1
#include <dragonfly_lib.h>
2

    
3

    
4
/**
5
 * RangeFinder Rules
6
 * - analog_init() is needed
7
 * - value 100 - under 5cm is not detected
8
 * - value 800 - over 30cm is not detected
9
 *
10
 */
11

    
12
int testrangefinders(void) {
13
  dragonfly_init(ANALOG);
14
  usb_init();
15
        usb_puts("usb turned on\r\n");
16
  range_init();
17
  usb_puts("rangefinders turned on\r\n");
18
  int d1,d2,d3,d4,d5;
19
  delay_ms(1000);
20
  
21
  // start testing rangefinders
22
  while(1) {
23
    // get ranges
24
    d1 = range_read_distance(IR1);
25
    d2 = range_read_distance(IR2);
26
    d3 = range_read_distance(IR3);
27
    d4 = range_read_distance(IR4);
28
    d5 = range_read_distance(IR5);
29
    usb_puts("d1=");
30
    usb_puti(d1);
31
    usb_puts("\td2=");
32
    usb_puti(d2);
33
    usb_puts("\td3=");
34
    usb_puti(d3);
35
    usb_puts("\td4=");
36
    usb_puti(d4);
37
    usb_puts("\td5=");
38
    usb_puti(d5);
39
    usb_puts("\r\n");    
40
    delay_ms(100);
41
  }
42
  
43
  // end testing rangefinders
44
        return 0;
45
}
46

    
47