赤外線リモコンの送信をパルス幅にて行います。 IRRcevPulseWidthライブラリと合わせて使ってください。 Transmit IR control by pulse width. Please use it together with the IRRcevPulseWidth library.
Dependents: IRLED_SendReceveDemo
Diff: IRSendPulseWidth.cpp
- Revision:
- 0:beaea9bf9c5b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IRSendPulseWidth.cpp Sun Dec 25 09:53:36 2016 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" +#include "IRSendPulseWidth.h" + +IRSendPulseWidth::IRSendPulseWidth(PinName output) : g_pwmoutLed(output) +{ + g_pwmoutLed.period_us(26); + g_pwmoutLed.write(0); +} + +void IRSendPulseWidth::sendSignal(uint16_t *sendDataArray,uint16_t sendDataN) +{ + int iCountHighLow = sendDataN; + for( int iIndexHighLow = 0; iIndexHighLow < iCountHighLow; iIndexHighLow++ ) + { + g_pwmoutLed.write( 0.5 * (1 - (iIndexHighLow % 2)) ); // iIndexHighLow : even number -> 0.5, uneven number -> 0 + wait_us( *(sendDataArray+iIndexHighLow) ); + } + g_pwmoutLed.write(0); +}