Para una proyecto
Revision 0:6106a82e900c, committed 2014-03-28
- Comitter:
- alonsoangulo
- Date:
- Fri Mar 28 15:51:25 2014 +0000
- Commit message:
- C?digo para medir distancia con EZ1 en comunicaci?n serial entre computadora y Freedom KL25Z
Changed in this revision
DistanceMaxSonar.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 6106a82e900c DistanceMaxSonar.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DistanceMaxSonar.h Fri Mar 28 15:51:25 2014 +0000 @@ -0,0 +1,24 @@ +#ifndef MBED_DISTANCEMAXSONAR_H +#define MBED_DISTANCEMAXSONAR_H + +#include "mbed.h" + +class DistanceMaxSonar { + public: + DistanceMaxSonar(PinName MaxS); + float GetInch(); + float GetFt(); + float Getcm(); + float GetM(); + + static int bar; + static void isr(); + + + + + + private: + AnalogIn _MaxS; +}; +#endif \ No newline at end of file
diff -r 000000000000 -r 6106a82e900c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Mar 28 15:51:25 2014 +0000 @@ -0,0 +1,27 @@ +#include "mbed.h" +#include "DistanceMaxSonar.h" + + +DistanceMaxSonar::DistanceMaxSonar(PinName MaxS): _MaxS(MaxS){ +} +float DistanceMaxSonar::GetInch(){ + float voltVal = _MaxS; + float inch; + inch = voltVal*515.625; + return inch; +} +float DistanceMaxSonar::GetFt(){ + float inch = GetInch(); + float Ft = inch/12.0; + return Ft; +} +float DistanceMaxSonar::Getcm(){ + float inch = GetInch(); + float cm = inch*2.54; + return cm; +} +float DistanceMaxSonar::GetM(){ + float ft = GetFt(); + float M = ft*0.3048; + return M; +} \ No newline at end of file