zhouhang shao / Mbed 2 deprecated test

Dependencies:   RemoteIR mbed

Files at this revision

API Documentation at this revision

Comitter:
szh66
Date:
Thu Mar 23 04:23:49 2017 +0000
Parent:
0:3c59bc5c9388
Child:
2:b78dfa2afe92
Commit message:
test

Changed in this revision

IRSensor.h Show annotated file Show diff for this revision Revisions of this file
RemoteIR.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/IRSensor.h	Sun Feb 26 20:29:20 2017 +0000
+++ b/IRSensor.h	Thu Mar 23 04:23:49 2017 +0000
@@ -1,5 +1,5 @@
-#ifndef IR_H
-#define IR_H
+#ifndef IRSENSOR_H
+#define IRSENSOR_H
 
 #include "mbed.h"
 
@@ -30,6 +30,7 @@
     float readIR(){
         float sum = 0;
 
+        
         //Each duration takes 100us, 5 times = 0.5ms
         for (int i = 0; i < 5; i++)
         {
@@ -64,7 +65,7 @@
         _value += COEFF_6 * square;
         _value += COEFF_7 * square * sum;
         
-        return _value;
+        return value;
     }
 
     //Get the number of cells away wall is
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteIR.lib	Thu Mar 23 04:23:49 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/shintamainjp/code/RemoteIR/#268cc2ab63bd
--- a/main.cpp	Sun Feb 26 20:29:20 2017 +0000
+++ b/main.cpp	Thu Mar 23 04:23:49 2017 +0000
@@ -3,21 +3,32 @@
 */
 
 #include "mbed.h"
-#include "ir.h"
- DigitalOut myLED (LED1);
+#include "IRSensor.h"
  Serial serial (USBTX, USBRX);
- IRSensor testIR (PA_7, PC_7);
+ IRSensor testIR (PC_7, PC_5); //pc7 is the output and pc5 is the input
+ DigitalOut testLed(PC_8);
+ 
  
  int main ()
  {
-     serial.printf ("Start Program \ n \ r");
+     serial.printf ("Start Program\n");
+     
+     
      while (1)
      {
-         serial.printf("read a val");
-         serial.print("value is: ", testIR.readIR(););
-         myLED = 1;
-         wait (0.2);
-         myLED = 0;
-         wait (1.0);
+         //serial.putc(serial.getc());
+         if(testIR.readIR()){
+              testLed = 1; 
+          
+            serial.printf("value is: %f\r\n", testIR.readIR());
+            wait (0.5);
+         }
+         else{
+            testLed = 1; 
+            wait (0.2);
+            testLed = 0; 
+            wait (0.2);
+         }     
+        
      }
  } 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Mar 23 04:23:49 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file