IR transmit and receive demo using Sparkfun breakout boards See http://mbed.org/users/4180_1/notebook/ir-and-rf-remote-controls/
main.cpp
00001 #include "mbed.h" 00002 00003 Serial pc(USBTX, USBRX); // tx, rx 00004 Serial device(p13, p14); // tx, rx 00005 DigitalOut myled1(LED1); 00006 DigitalOut myled2(LED2); 00007 PwmOut IRLED(p21); 00008 //IR send and receive demo 00009 //LED1 and LED2 indicate TX/RX activity 00010 //Character typed in PC terminal application sent out and returned back using IR transmitter and receiver 00011 00012 int main() { 00013 //IR Transmit code 00014 IRLED.period(1.0/38000.0); 00015 IRLED = 0.5; 00016 //Drive IR LED data pin with 38Khz PWM Carrier 00017 //Drive IR LED gnd pin with serial TX 00018 device.baud(2400); 00019 while(1) { 00020 if(pc.readable()) { 00021 myled1 = 1; 00022 device.putc(pc.getc()); 00023 myled1 = 0; 00024 } 00025 //IR Receive code 00026 if(device.readable()) { 00027 myled2 = 1; 00028 pc.putc(device.getc()); 00029 myled2 = 0; 00030 } 00031 } 00032 }
Generated on Wed Jul 13 2022 13:30:38 by 1.7.2