chen ada
/
IR_remote_demo_code
使用红外接收库的一个demo code
Fork of IR_remote by
Diff: main.cpp
- Revision:
- 2:35f80e65a141
- Parent:
- 1:5e7be7addf96
- Child:
- 3:29915623fbb0
--- a/main.cpp Thu Jul 13 08:07:25 2017 +0000 +++ b/main.cpp Thu Jul 13 11:37:43 2017 +0000 @@ -1,5 +1,12 @@ #include "mbed.h" #include "ReceiverIR.h" + +DigitalOut my_led(LED1); + +PwmOut my_pwm1(PB_3); +PwmOut my_pwm2(PB_5); + + ReceiverIR ir_rx(D2); Serial pc(SERIAL_TX, SERIAL_RX); @@ -8,9 +15,17 @@ RemoteIR::Format format; uint8_t buf[32]; int bitcount; +float DC=0.5; int main() { + my_pwm1.period_ms(10); + my_pwm1.write(DC); + + my_pwm2.period_ms(10); + my_pwm2.write(DC); + + pc.printf("Hello World !\r\n"); while(1) { @@ -22,6 +37,22 @@ pc.printf("Decoded: %02X \r\n", buf[3]); myled = !myled; + + if (buf[3]==0xE5){ + DC = DC+ 0.1; + if (DC>1) DC=1; + } + if (buf[3]==0xD4){ + DC = DC- 0.1; + if (DC<0) DC=0; + } + if (buf[3]==0xC3){ + DC = 0.5; + } + + my_pwm1.write(DC); + my_pwm2.write(DC); + /* DEBUG for (int i = 0; i < bitcount; i++) {