READY TO RUMBLE
Dependencies: mbed
Fork of Micromouse_alpha_copy_copy by
IRSensor.cpp
- Committer:
- ruesipat
- Date:
- 2018-03-07
- Revision:
- 0:a9fe4ef404bf
- Child:
- 1:d9e840c48b1e
File content as of revision 0:a9fe4ef404bf:
#include <cmath> #include "IRSensor.h" using namespace std; IRSensor::IRSensor(AnalogIn& distance, DigitalOut& bit0, DigitalOut& bit1, DigitalOut& bit2, int number) : distance(distance), bit0(bit0), bit1(bit1), bit2(bit2) { this->number = number; } IRSensor::~IRSensor() {} float IRSensor::read() { bit0 = (number >> 0) & 1; bit1 = (number >> 1) & 1; bit2 = (number >> 2) & 1; float d = -0.58f*sqrt(distance)+0.58f; // Lesen der Distanz in [m] return d; }