a demo code to get ir data via an ir remote control recevier

Dependencies:   mbed

Committer:
cstevens
Date:
Thu May 22 11:30:43 2014 +0000
Revision:
0:ed79162edfb0
demo code for ir data on tsmp1138 - transmits data across ir link

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cstevens 0:ed79162edfb0 1 #include "mbed.h"
cstevens 0:ed79162edfb0 2 /*demo program to test ir data transmission using a tsmp1138 ir receiver and an IR LED
cstevens 0:ed79162edfb0 3 code for an FRDM-KL25Z
cstevens 0:ed79162edfb0 4 connections are LED negative to the serial TC and the positive to the PWM.
cstevens 0:ed79162edfb0 5 The output from the tsmp1138 icarries the 38khz modulation and hence requires a smoothing cap to
cstevens 0:ed79162edfb0 6 allow simple serial detection. 3.3nF between the output and ground from the tsmp1138 is sufficient.
cstevens 0:ed79162edfb0 7 */
cstevens 0:ed79162edfb0 8 DigitalOut myled(LED2);
cstevens 0:ed79162edfb0 9 PwmOut carrier(PTA5);
cstevens 0:ed79162edfb0 10 Serial TX(PTC4,PTC3);
cstevens 0:ed79162edfb0 11 Serial RX(PTD3,PTD2);
cstevens 0:ed79162edfb0 12 Serial pc(USBTX,USBRX);
cstevens 0:ed79162edfb0 13
cstevens 0:ed79162edfb0 14 static char message[]="One Fine DAy In the Middle of the Night\n";
cstevens 0:ed79162edfb0 15
cstevens 0:ed79162edfb0 16 int main() {
cstevens 0:ed79162edfb0 17 char c;
cstevens 0:ed79162edfb0 18 pc.printf("start\n\r");
cstevens 0:ed79162edfb0 19 int n;
cstevens 0:ed79162edfb0 20 //set up the twp ports
cstevens 0:ed79162edfb0 21 RX.baud(1000);
cstevens 0:ed79162edfb0 22 TX.baud(1000);
cstevens 0:ed79162edfb0 23 carrier.period(1.0/38000.0);
cstevens 0:ed79162edfb0 24 carrier=0.5;
cstevens 0:ed79162edfb0 25 n=0;
cstevens 0:ed79162edfb0 26 while(1) {
cstevens 0:ed79162edfb0 27 TX.putc(message[n]);
cstevens 0:ed79162edfb0 28 n=(n+1)%sizeof(message);
cstevens 0:ed79162edfb0 29 wait(0.05);
cstevens 0:ed79162edfb0 30 myled=!myled;
cstevens 0:ed79162edfb0 31 c=RX.getc();
cstevens 0:ed79162edfb0 32 pc.putc(c);
cstevens 0:ed79162edfb0 33 }
cstevens 0:ed79162edfb0 34 }