para la tarea

Files at this revision

API Documentation at this revision

Comitter:
alonsoangulo
Date:
Thu Mar 27 23:34:51 2014 +0000
Commit message:
dfafs

Changed in this revision

Distance_sensor.cpp Show annotated file Show diff for this revision Revisions of this file
Distance_sensor.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 8d03124897ca Distance_sensor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Distance_sensor.cpp	Thu Mar 27 23:34:51 2014 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "DistanceMaxSonar.h"
+ 
+ DigitalOut myled(LED1);
+while(1){
+    myled=1;
+    }
+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
diff -r 000000000000 -r 8d03124897ca Distance_sensor.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Distance_sensor.h	Thu Mar 27 23:34:51 2014 +0000
@@ -0,0 +1,21 @@
+#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();
+        
+    
+    private:
+        AnalogIn _MaxS;
+};
+#endif
+        
\ No newline at end of file