chris stevens
/
IRtsmp1138demo
a demo code to get ir data via an ir remote control recevier
Diff: main.cpp
- Revision:
- 0:ed79162edfb0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 22 11:30:43 2014 +0000 @@ -0,0 +1,34 @@ +#include "mbed.h" +/*demo program to test ir data transmission using a tsmp1138 ir receiver and an IR LED +code for an FRDM-KL25Z +connections are LED negative to the serial TC and the positive to the PWM. +The output from the tsmp1138 icarries the 38khz modulation and hence requires a smoothing cap to +allow simple serial detection. 3.3nF between the output and ground from the tsmp1138 is sufficient. +*/ +DigitalOut myled(LED2); +PwmOut carrier(PTA5); +Serial TX(PTC4,PTC3); +Serial RX(PTD3,PTD2); +Serial pc(USBTX,USBRX); + +static char message[]="One Fine DAy In the Middle of the Night\n"; + +int main() { + char c; + pc.printf("start\n\r"); + int n; + //set up the twp ports + RX.baud(1000); + TX.baud(1000); + carrier.period(1.0/38000.0); + carrier=0.5; + n=0; + while(1) { + TX.putc(message[n]); + n=(n+1)%sizeof(message); + wait(0.05); + myled=!myled; + c=RX.getc(); + pc.putc(c); + } +}