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.
main.cpp
- Committer:
- Faridzaher
- Date:
- 2014-03-29
- Revision:
- 0:d3f1f650e365
File content as of revision 0:d3f1f650e365:
#include "mbed.h"
#include "SonicD.h"
/*class SonicD{
public:
InterruptIn nombre;//(sonicPW);
Timer t;
SonicD(PinName sonicPW) : nombre(sonicPW){
nombre.rise(this, &SonicD::rise_int);
nombre.fall(this, &SonicD::get_uS);
}
volatile float dcm;
volatile float din;
float getIn(){
din = uS/147.0;
return din;
}
float getCm(){
dcm = (uS/147.0)*2.54;
return dcm;
}
void rise_int(){
t.start();
}
void get_uS(){
uS = t.read_us();
t.reset();
}
private:
volatile int uS;
};
*/
//---------------------------------------------------------------------
Serial pc(USBTX, USBRX);
SonicD sensor(PTA12);
int main() {
while(1){
wait(0.2);
int x = sensor.getIn();
int y = sensor.getCm();
pc.printf("%i in\t%i cm\n", x, y);
}
}