10 years, 9 months ago.

how to use mbed with IR TX/RX

Hi

I want to use Mbed for my project. Actually what i have to do is to get codes from any IR remote control (AC remote in my case). and transmit these codes using mbed via IR transmitter. I need help how to get codes from the remote and transfer it. I am using the simple 3pin IR receiver , and IR transmitter LED.

can anyone direct me to something useful ?

Thank You

hi Aftab !! you can test this program with simple IR receiver component, this helps you to get(display) codes of a remote controller . program:

  1. include <mbed.h>
  2. include "ReceiverIR.h"

ReceiverIR ir_rx(p12); Serial pc(USBTX, USBRX); tx, rx

int receive(RemoteIR::Format *format, uint8_t *buf, int bufsiz, int timeout = 1000) { int cnt = 0; while (ir_rx.getState() != ReceiverIR::Received) { wait_ms(1); cnt++; if (timeout < cnt) { return -1;}} pc.printf("getstat:%x\n",ir_rx.getState());}} return ir_rx.getData(format, buf, bufsiz * 8);}

void display_data(uint8_t *buf, int bitlength) { const int n = bitlength / 8 + (((bitlength % 8) != 0) ? 1 : 0); for (int i = 0; i < n; i++) { pc.printf("%x", buf[i]); } pc.printf(" \n ");}

int main(void) { while (1) { uint8_t buf1[32]; int bitlength1; RemoteIR::Format format; memset(buf1, 0x00, sizeof(buf1)); bitlength1 = receive(&format, buf1, sizeof(buf1)); display_data(buf1, bitlength1); }}

posted by Nacer ABBAS 07 May 2016

2 Answers

10 years, 9 months ago.

Have a look at: http://mbed.org/cookbook/IR

Accepted Answer
Syed Aftab
poster
10 years, 9 months ago.

Thank You Erik

I have looked at it but what i want to do is to write some data my self like

I i want to transfer "ABC" over the internet how can i do that ??

any idea codes etc that can be used

Thank you

Where did the internet suddenly come from? And where do you want to transmit ABC to?

posted by Erik - 17 Jul 2013

Thanks Erik i was busy in some other stuff that's why couldn't respond actually i want to control AC using mbed now i have to transmit the ON/OFF IR codes using mbed and IR transmitter ...these codes you know are sequences like ...Abhsjhdjsh34jh5jh5j4h52...etc .

This is why i asked how can i trasnfer data using IR . there no internet that was a mistake :(

posted by Syed Aftab 01 Aug 2013