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.
Fork of Micromouse_beta 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; }