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 DRV88255 TextLCD Ping mbed-rtos
ProximityController.cpp
- Committer:
- joran
- Date:
- 2016-06-20
- Revision:
- 66:133398875949
- Parent:
- 58:b5f0c0f305ff
- Child:
- 68:b769c0f23406
File content as of revision 66:133398875949:
#include "ProximityController.h"
static Ping pinger(p30);
static DigitalOut alarmled(LED3);
void ProximityController::update() {
int range;
pinger.Send();
Thread::wait(30);
range = pinger.Read_cm()/ 2;
this->distance = (float)range;
}
float ProximityController::getDistance() {
return this->distance;
}
float ProximityController::getValue() {
this->volume = (DISTANCE_TO_BASE - this->distance) * ((100/12) *10);
return this->volume;
}
std::string ProximityController::getName() {
return "ProximityController";
}
void ProximityController::setLed(bool value){
if (value) alarmled = 1;
if (!value) alarmled = 0;
}