赤外線リモコンの送信をパルス幅にて行います。 IRRcevPulseWidthライブラリと合わせて使ってください。 Transmit IR control by pulse width. Please use it together with the IRRcevPulseWidth library.
Dependents: IRLED_SendReceveDemo
IRSendPulseWidth.cpp
00001 #include "mbed.h" 00002 #include "IRSendPulseWidth.h" 00003 00004 IRSendPulseWidth::IRSendPulseWidth(PinName output) : g_pwmoutLed(output) 00005 { 00006 g_pwmoutLed.period_us(26); 00007 g_pwmoutLed.write(0); 00008 } 00009 00010 void IRSendPulseWidth::sendSignal(uint16_t *sendDataArray,uint16_t sendDataN) 00011 { 00012 int iCountHighLow = sendDataN; 00013 for( int iIndexHighLow = 0; iIndexHighLow < iCountHighLow; iIndexHighLow++ ) 00014 { 00015 g_pwmoutLed.write( 0.5 * (1 - (iIndexHighLow % 2)) ); // iIndexHighLow : even number -> 0.5, uneven number -> 0 00016 wait_us( *(sendDataArray+iIndexHighLow) ); 00017 } 00018 g_pwmoutLed.write(0); 00019 }
Generated on Tue Jul 26 2022 18:16:01 by 1.7.2