赤外線リモコンの送信をパルス幅にて行います。 IRRcevPulseWidthライブラリと合わせて使ってください。 Transmit IR control by pulse width. Please use it together with the IRRcevPulseWidth library.

Dependents:   IRLED_SendReceveDemo

Committer:
nameless129
Date:
Sun Dec 25 09:53:36 2016 +0000
Revision:
0:beaea9bf9c5b
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nameless129 0:beaea9bf9c5b 1 #include "mbed.h"
nameless129 0:beaea9bf9c5b 2 #include "IRSendPulseWidth.h"
nameless129 0:beaea9bf9c5b 3
nameless129 0:beaea9bf9c5b 4 IRSendPulseWidth::IRSendPulseWidth(PinName output) : g_pwmoutLed(output)
nameless129 0:beaea9bf9c5b 5 {
nameless129 0:beaea9bf9c5b 6 g_pwmoutLed.period_us(26);
nameless129 0:beaea9bf9c5b 7 g_pwmoutLed.write(0);
nameless129 0:beaea9bf9c5b 8 }
nameless129 0:beaea9bf9c5b 9
nameless129 0:beaea9bf9c5b 10 void IRSendPulseWidth::sendSignal(uint16_t *sendDataArray,uint16_t sendDataN)
nameless129 0:beaea9bf9c5b 11 {
nameless129 0:beaea9bf9c5b 12 int iCountHighLow = sendDataN;
nameless129 0:beaea9bf9c5b 13 for( int iIndexHighLow = 0; iIndexHighLow < iCountHighLow; iIndexHighLow++ )
nameless129 0:beaea9bf9c5b 14 {
nameless129 0:beaea9bf9c5b 15 g_pwmoutLed.write( 0.5 * (1 - (iIndexHighLow % 2)) ); // iIndexHighLow : even number -> 0.5, uneven number -> 0
nameless129 0:beaea9bf9c5b 16 wait_us( *(sendDataArray+iIndexHighLow) );
nameless129 0:beaea9bf9c5b 17 }
nameless129 0:beaea9bf9c5b 18 g_pwmoutLed.write(0);
nameless129 0:beaea9bf9c5b 19 }