zhouhang shao
/
test
test
Diff: main.cpp
- Revision:
- 1:11970e541ecf
- Parent:
- 0:3c59bc5c9388
- Child:
- 2:b78dfa2afe92
--- 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