Basic HelloWorld on how to use LidarLitev2
Dependencies: LidarLitev2 mbed
Distance.cpp@0:1c42ae9ef9a2, 2015-10-22 (annotated)
- Committer:
- sventura3
- Date:
- Thu Oct 22 21:36:14 2015 +0000
- Revision:
- 0:1c42ae9ef9a2
Basic HelloWorld on how to use LidarLitev2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sventura3 | 0:1c42ae9ef9a2 | 1 | #include "LidarLitev2.h" |
sventura3 | 0:1c42ae9ef9a2 | 2 | |
sventura3 | 0:1c42ae9ef9a2 | 3 | |
sventura3 | 0:1c42ae9ef9a2 | 4 | LidarLitev2 Lidar(p28, p27); |
sventura3 | 0:1c42ae9ef9a2 | 5 | Serial pc(USBTX,USBRX); |
sventura3 | 0:1c42ae9ef9a2 | 6 | |
sventura3 | 0:1c42ae9ef9a2 | 7 | |
sventura3 | 0:1c42ae9ef9a2 | 8 | Timer dt; |
sventura3 | 0:1c42ae9ef9a2 | 9 | int main() |
sventura3 | 0:1c42ae9ef9a2 | 10 | { |
sventura3 | 0:1c42ae9ef9a2 | 11 | |
sventura3 | 0:1c42ae9ef9a2 | 12 | pc.baud(115200); |
sventura3 | 0:1c42ae9ef9a2 | 13 | Lidar.configure(); |
sventura3 | 0:1c42ae9ef9a2 | 14 | dt.start(); |
sventura3 | 0:1c42ae9ef9a2 | 15 | while(1){ |
sventura3 | 0:1c42ae9ef9a2 | 16 | pc.printf("distance = %d cm frequency = %.2f Hz\n", Lidar.distance(), 1/dt.read()); |
sventura3 | 0:1c42ae9ef9a2 | 17 | dt.reset(); |
sventura3 | 0:1c42ae9ef9a2 | 18 | } |
sventura3 | 0:1c42ae9ef9a2 | 19 | } |