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.
Dependencies: mbed
IR_Sensor.cpp
- Committer:
- Alexander_Zuest
- Date:
- 2018-04-27
- Revision:
- 1:aa9eda7db520
- Parent:
- 0:b3438c44da56
File content as of revision 1:aa9eda7db520:
#include <cmath>
#include "IR_Sensor.h"
using namespace std;
IR_Sensor::IR_Sensor (AnalogIn& distance, DigitalOut& bit0,DigitalOut& bit1, DigitalOut& bit2, int number) : distance(distance), bit0(bit0), bit1(bit1), bit2(bit2)
{
this -> number = number;
}
IR_Sensor::~IR_Sensor() {} //Destruktor
float IR_Sensor::read() { //Methode
{
bit0 = (number >> 0) & 1;
bit1 = (number >> 1) & 3;
bit2 = (number >> 2) & 2;
float d = -0.58f*squrt(distance)+0.58f; //Lesen der Distance
return d;
}