Sharp IR Distance Sensor
Dependents: NavigationTest_ NavigationTest theRobotNEW theRobot ... more
Sharp.cpp@0:04f1a022d4d0, 2013-12-12 (annotated)
- Committer:
- tashworth
- Date:
- Thu Dec 12 19:25:15 2013 +0000
- Revision:
- 0:04f1a022d4d0
- Child:
- 1:a5ced48cfedc
Sharp IR distance sensor library.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tashworth | 0:04f1a022d4d0 | 1 | #include "Sharp.h" |
tashworth | 0:04f1a022d4d0 | 2 | #include "mbed.h" |
tashworth | 0:04f1a022d4d0 | 3 | #include "math.h" |
tashworth | 0:04f1a022d4d0 | 4 | |
tashworth | 0:04f1a022d4d0 | 5 | Sharp::Sharp( PinName voutPin ): |
tashworth | 0:04f1a022d4d0 | 6 | vout(voutPin) |
tashworth | 0:04f1a022d4d0 | 7 | { |
tashworth | 0:04f1a022d4d0 | 8 | } |
tashworth | 0:04f1a022d4d0 | 9 | |
tashworth | 0:04f1a022d4d0 | 10 | double Sharp::getDistance(void) |
tashworth | 0:04f1a022d4d0 | 11 | { |
tashworth | 0:04f1a022d4d0 | 12 | float dist = vout.read(); |
tashworth | 0:04f1a022d4d0 | 13 | |
tashworth | 0:04f1a022d4d0 | 14 | return 37.115*dist*dist-73.021*dist+43.451; |
tashworth | 0:04f1a022d4d0 | 15 | } |