![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
IR receiver for TG-LPC11U35-501
Diff: main.cpp
- Revision:
- 0:8ae7470a57ef
- Child:
- 2:31c91b18bba9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jun 22 09:54:10 2014 +0000 @@ -0,0 +1,92 @@ +//********************** +// Infrared Rays receiver sample for mbed +// +// LPC1768 flash=512KB, ADC=12bits +// LPC11U35 flash=64KB, ADC=10bits +// Nucleo F401RE flash=512KB, ADC=12bits +// +// (C)Copyright 2014 All rights reserved by Y.Onodera +// http://einstlab.web.fc2.com +//********************** +#include "mbed.h" +#include "AQM0802.h" +#include "IR.h" + +//#pragma O0 +//#pragma O1 +//#pragma O2 // default +//#pragma O3 +//#pragma Otime +//#pragma Ospace + + +#if defined(TARGET_LPC1768) +DigitalOut led1(LED1); +DigitalOut led2(LED2); +I2C i2c(p28,p27); +AnalogIn ain(p15); +#endif +// for TG-LPC11U35-501 +#if defined (TARGET_LPC11U35_501) +DigitalOut led1(P0_20); +DigitalOut led2(P0_21); +I2C i2c(P0_5,P0_4); +AnalogIn ain(P0_11); +#endif +// for Nucleo +#if defined (TARGET_NUCLEO_F401RE) +DigitalOut led1(D13); +I2C i2c(D14,D15); +AnalogIn ain(PA_0); +#endif + +AQM0802 lcd(i2c); +IR ir(P0_12); +InterruptIn button(P0_12); + +void flip() +{ + led1=!led1; + button.disable_irq(); + ir.GetIR(); + button.enable_irq(); + + // To do something, code here + +} + +int main() { + + char msg[10]; + char i; + + button.fall(&flip); + button.mode(PullUp); + + sprintf(msg, "%d", SystemCoreClock ); + lcd.locate(0,0); + lcd.print(msg); + wait(1); + + while(1) { + + lcd.locate(0,0); + sprintf(msg,"%02X",ir.bits); // bits + lcd.print(msg); + sprintf(msg,"%02X",ir.mode); // 1:NEC, 2:STD + lcd.print(msg); + + for(i=0;i<2;i++){ + sprintf(msg,"%02X",ir.buf[i]); // data + lcd.print(msg); + } + + lcd.locate(0,1); + for(i=2;i<6;i++){ + sprintf(msg,"%02X",ir.buf[i]); // data + lcd.print(msg); + } + wait(1); + } + +}