Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
IRSensor.cpp@29:0419f4873807, 2018-05-18 (annotated)
- Committer:
- Helvis
- Date:
- Fri May 18 09:30:00 2018 +0000
- Revision:
- 29:0419f4873807
- Parent:
- 21:41997651337a
v2.2d;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Helvis | 1:2b5f79285a3e | 1 | #include <cmath> |
| Helvis | 1:2b5f79285a3e | 2 | #include "IRSensor.h" |
| Helvis | 1:2b5f79285a3e | 3 | |
| Helvis | 1:2b5f79285a3e | 4 | using namespace std; |
| Helvis | 1:2b5f79285a3e | 5 | |
| Helvis | 1:2b5f79285a3e | 6 | IRSensor::IRSensor(AnalogIn& distance) : |
| Helvis | 1:2b5f79285a3e | 7 | distance(distance){} |
| Helvis | 1:2b5f79285a3e | 8 | |
| Helvis | 1:2b5f79285a3e | 9 | IRSensor::~IRSensor() {} |
| Helvis | 1:2b5f79285a3e | 10 | |
| Helvis | 1:2b5f79285a3e | 11 | float IRSensor::readL() { |
| Helvis | 1:2b5f79285a3e | 12 | //Links B2 |
| Helvis | 3:076dd7ec7eb4 | 13 | float d2 = 10.2817f*(1/(pow(distance,1.212121f))); |
| Helvis | 1:2b5f79285a3e | 14 | |
| Helvis | 1:2b5f79285a3e | 15 | return d2; |
| Helvis | 1:2b5f79285a3e | 16 | |
| Helvis | 1:2b5f79285a3e | 17 | } |
| Helvis | 1:2b5f79285a3e | 18 | |
| Helvis | 1:2b5f79285a3e | 19 | float IRSensor::readR(){ |
| Helvis | 1:2b5f79285a3e | 20 | //Rechts B1 |
| Helvis | 3:076dd7ec7eb4 | 21 | float d1 = 11.6037f*(1/(pow(distance,1.111111f))); |
| Helvis | 1:2b5f79285a3e | 22 | |
| Helvis | 1:2b5f79285a3e | 23 | return d1; |
| Helvis | 1:2b5f79285a3e | 24 | } |
| Helvis | 1:2b5f79285a3e | 25 | |
| Helvis | 1:2b5f79285a3e | 26 | float IRSensor::readC(){ |
| Helvis | 29:0419f4873807 | 27 | //Vorne B3 |
| Helvis | 29:0419f4873807 | 28 | //float d4 = 28.053f*(1.0f/distance); |
| Helvis | 29:0419f4873807 | 29 | float d4 = 32.887f*(1/(pow(distance,1.038422f))); |
| Helvis | 1:2b5f79285a3e | 30 | |
| Helvis | 1:2b5f79285a3e | 31 | return d4; |
| Helvis | 1:2b5f79285a3e | 32 | } |
| Helvis | 1:2b5f79285a3e | 33 | |
| Helvis | 1:2b5f79285a3e | 34 | //float IRSensor::readB(){} |
