Sending Infrared commands (FEZ Spider starter kit + IR Transmitter (Devhammer module) )

Hello,

I have managed to read IR commands from my Philips Stereo using Arduino and an infrared receiver.

The question is how and in what format can I now send the code to my Stereo to power it on without a remote control? (Using Devhammer module)

It has a driver built in using Signal generator class

How can I send the command using this module?

could anyone give me an example with the source code bellow how should I do that?

I add the received IR signal bellow that I would like to send.

Thank you for your support.

//pover
Received:

OFF ON
37668 usec, 2680 usec
840 usec, 460 usec
840 usec, 460 usec
420 usec, 460 usec
400 usec, 480 usec
840 usec, 900 usec
400 usec, 460 usec
420 usec, 460 usec
420 usec, 900 usec
840 usec, 900 usec
840 usec, 900 usec
860 usec, 460 usec
420 usec, 460 usec
400 usec, 480 usec
400 usec, 900 usec
420 usec, 460 usec
840 usec, 460 usec
400 usec, 480 usec
int IRsignal[] = {
// ON, OFF
pulseIR(2680);
delayMicroseconds(840);
pulseIR(460);
delayMicroseconds(840);
pulseIR(460);
delayMicroseconds(420);
pulseIR(460);
delayMicroseconds(400);
pulseIR(480);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(400);
pulseIR(460);
delayMicroseconds(420);
pulseIR(460);
delayMicroseconds(420);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(840);
pulseIR(900);
delayMicroseconds(860);
pulseIR(460);
delayMicroseconds(420);
pulseIR(460);
delayMicroseconds(400);
pulseIR(480);
delayMicroseconds(400);
pulseIR(900);
delayMicroseconds(420);
pulseIR(460);
delayMicroseconds(840);
pulseIR(460);
delayMicroseconds(400);
pulseIR(480);

For now, forget the driver code, since it’s not really necessary.

Plug your IR emitter module into a socket that supports X or Y (should be labeled on the mainboard). From earlier discussions, you said you have your own home-made version of the IR LED Array module, based on my design. Assuming you wired it the same as I did, the signal pin should be pin 5.

Don’t worry about adding anything in the Gadgeteer designer for the IR module. Add a button to the designer to trigger the output.

Inside the Program class declaration, just before the ProgramStarted function, add a static variable for your SignalCapture instance:

static SignalCapture irSignal;

Note that you will need to add a reference to the GHI.Hardware assembly (right-click References in your project, and select GHI.Hardware from the list), and also add a using reference to GHI.IO.

In Program.cs, in the ProgramStarted function, add code to wire up the button.ButtonPressed event handler:


button.ButtonPressed += button_ButtonPressed;

Note that if you type button.ButtonPressed += you should then be prompted to hit TAB twice to automatically create the event handler.

Also in ProgramStarted, add the code necessary to wire up the IR module, like so:


            // replace YOUR_SOCKET_NUMBER with the socket number you plugged
            // the IR emitter module into
            Socket socket = Socket.GetSocket(YOUR_SOCKET_NUMBER, false, null, "X");
            irSigGen = new SignalGenerator(Socket.GetSocket(8, false, null, null).CpuPins[5], true);

Now, in your button event handler, you can send the signal:


void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
{
   button.TurnLedOn();
   irSigGen.SetBlocking(true, buffer, 0, buffer.Length, true, 1000, 38000);
   button.TurnLedOff();
}

3 things to note about the above code:

  1. The “buffer” argument is where the list of timings should go.
  2. I’m turning the button LED on and off because the call to SetBlocking is a blocking call, so with the LED I can tell when the command has finished sending.
  3. The 38000 argument to SetBlocking is the carrier frequency. This needs to be within a certain margin of what your receiving device expects in order to work. If you know what frequency the device operates on, then use that value for this argument. Otherwise, you may need to experiment.

Now, in terms of getting the buffer value, it should be declared in your code as a uint array, like so:


static uint[] buffer = new uint[] { VALUES };

with VALUES replaced by the list of values you recorded from your remote. Based on your list of values above, that should look something like the following:


static uint[] buffer = new uint[] { 2680,840,460,840,460,420,460,400,480,840,900,400,460,420,460,420,900,840,900,840,900,860,460,420,460,400,480,400,900,420,460,840,460,400,480 };

It’s important to note…you need to make sure that when you send, you’re sending the correct initial state (true/false or on/off). Looking at the values you posted, it appears that the first value (2680) is an ON pulse, so in theory, calling SetBlocking with a first argument of true should work. But you may have to experiment with changing that to false, as well as experiment with the initialValue argument of the SignalGenerator constructor.

I was able to put together a project using a GHI eblock IR receiver to read IR values (when a button was pressed) from a toy bug robot that uses IR for control, save the resulting values out to Excel (copied from the Locals window), copied just the timing values to Word, used the Replace feature to replace ^p (paragraph mark) with a comma, which gave me the values I needed to send to the SetBlocking method.

I set up my IR LED Array module on socket 8, and had it send commands when another button was pressed, similar to the code above.

One last note. Make sure that your device uses the wavelength and carrier frequency you think it does. The module I designed is made for use with 940nm IR LEDs, which should be the most common. Likewise, the projects I’ve done have typically used a carrier frequency of 38khz, but that’s not the only carrier frequency you’ll find. According to http://en.wikipedia.org/wiki/Consumer_IR#Technical_information, “The Philips RC-5 and RC-6 protocols both specify a carrier frequency of 36 kHz.” So you may need to adjust the carrier frequency in the code above to 36000 in order to make it work.

More information is available at https://learn.adafruit.com/ir-sensor?view=all, which I urge you to read in full, and then re-read. It is essential that you have a full understanding of how IR works in order to troubleshoot what your code is or isn’t doing. Do note that the Adafruit tutorial discusses using PWM to generate the carrier frequency, and then turning that PWM signal on/off. In the case of the code above, it is the SignalGenerator class that performs both tasks.

This should give you everything you need to successfully send IR commands using Gadgeteer hardware.

One other thing of note.

In the case of the IR-controlled toy (a robot bug) that I was using for this, it appears that the remote controller actually sends the command twice, probably because the tolerance in the timings being sent is pretty loose. I found that if I cut out the second half of the timings (there were two very long values that made obvious cut-off points for the end of the signal), it still worked, but not 100% reliably.

With a commercial product like a stereo receiver, I’d expect the timings to be a little more reliable, but something to watch out for.

This may also prove useful in dealing with Philips devices using the RC-5 protocol:

http://www.pcbheaven.com/userpages/The_Philips_RC5_Protocol/

as well as this:

http://www.sbprojects.com/knowledge/ir/rc5.php

and this:

If possible, I’d recommend verifying that your Philips stereo is using RC-5. Given that RC-5 uses a 36khz carrier frequency rather than 38khz, that might make a difference in making this work. Likewise, the timings you list in your initial post in this thread don’t seem to match up to what I’m reading about the RC-5 protocol, so it may be that this particular device uses something different.

2 Likes

Devhammer,

Sincerely I thank you for your reply to my post.

I will try to do that tomorrow. See how it goes.

Yes ,the Philips Audio set does not use RC5 protocol.I don’t actually know wich one it does use but i’m sure it’s not RC5

I will try to experiment with it and tell you how it goes.

Have a great weekend.

It says :

Error 1 ‘GHI.Premium.Hardware.SignalGenerator’ does not contain a constructor that takes 2 arguments D:\TEST_IRLED\IRLED\IRLED\Program.cs 46 24 IRLED

I did as you told me i don’t know what seems to be the problem.

I add you the source code bellow


namespace IRLED
{
    public partial class Program
    {
     
        static SignalGenerator irSigGen;
        static uint[] buffer = new uint[] { 2680, 840, 460, 840, 460, 420, 460, 400, 480, 840, 900, 400, 460, 420, 460, 420, 900, 840, 900, 840, 900, 860, 460, 420, 460, 400, 480, 400, 900, 420, 460, 840, 460, 400, 480 };
       
        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {
            button.TurnLEDOn();
            irSigGen.SetBlocking(true, buffer, 0, buffer.Length, 1000 ,true,38000);
            button.TurnLEDOff();
        }

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {

            button.ButtonPressed += button_ButtonPressed;



            Debug.Print("Program Started");

            Socket socket = Socket.GetSocket(4, false, null, "X");
            irSigGen = new SignalGenerator(Socket.GetSocket(4,false, null, null).CpuPins[5], true);

 Debug.Print("Program died");
        }
    }
}




@ geduxadmin - It looks like you’re using NETMF 4.2, rather than 4.3. Is that correct?

If so, it appears that the SignalGenerator constructor differs from 4.2 to 4.3. My examples were based on 4.3. In 4.2, you need to add another parameter to the constructor, an int representing the max buffer size for the timings, which should be the same as the length of your buffer (looks to be 35, but you should double-check that):


irSigGen = new SignalGenerator(Socket.GetSocket(4,false, null, null).CpuPins[5], true, 35);

Something to keep in mind. Intellisense is your friend. If you left out a constructor argument, there should be a red squiggly line under the line of code where the error is. And as you’re typing the code for the constructor, Intellisense will show you the parameters that are expected.

Hope that helps.

it does not work.The program compiles everything is fine if i press the button the LED somehow blinks a little (I can hardly see that with my camera but i do when i turn off the lights.But my device does not recognize anything.

IF i press a button via gadgeteer added remote from the IR sender my device recognizes that it’s a remote but does nothing.

Why my stereo does not recognize that a Transmitter devhammer module is trying to send something?

http://www.priceminister.com/offer/buy/221479484/telecommande-philips-rc2023631-01-pour-mcm-166.html

It is a link to the stereo set remote control

I just don’t understand why it does not recognize it.

There are a variety of reasons why it might not work:

  1. Your timings may be wrong.
  2. Your IR LEDs might not be the correct wavelength (I use 940nm LEDs, but it’s possible the remote for your stereo uses a different wavelength).
  3. Your carrier frequency could be off (typical is 38khz, but some remotes use 36khz, 40hkz, or other frequencies).

It’s not clear from your post how you recorded the original timings (i.e. with what hardware), so I’ve no way to know what wavelength and/or carrier frequency your particular IR receiver is tuned for. If those are sufficiently different from what the IR LED Array (transmitter) is tuned for, then that could cause issues).

Another thing to watch out for is interference. Both fluorescent light fixtures and sunlight can cause interference with IR signals. While this shouldn’t be a big deal with the remotes that come with a device, it may be more of an issue with the IR transmitter, particularly if either the wavelength or carrier frequency aren’t exactly what the device expects.

If what you are looking for is someone to give you the exact code that will work for your device, that’s probably not going to happen. None of us have your device in front of us, so it will require experimentation on your part to make this work. I’ve sent you many links to resources on IR protocols and interfacing with IR from microcontrollers. Take the time to read and understand those, and use the information to experiment with the code you’ve written. If you’re making the IR LEDs flash, then the module is working, and the challenge becomes making sure you are sending the right information to the device.

You may also want to consider trying a different target device. If you have something else handy that is controlled via IR, perhaps you could try that instead, and see if you have better luck capturing and playing back the timings.

Last, but not least, if you really want to make this work, you probably need to figure out what protocol the remote for your stereo is using. This app might help:

http://www.ostan.cz/IR_protocol_analyzer/

I have not used the app, but it looks like you could use it to view and analyze the signals from your remote, and determine what protocol it’s using. Note that you will need to have a phototransistor that can sense IR, and connect that to a microphone cable that fits your PC’s mic jack. There are instructions in the user documentation PDF linked at the above site.

LED,s are the same you are using.

How can i use signal capture to capture the signal and then replay it with Signal generator ? I have the GHI IR Receiver.Is there a depth guide how to use the signal capture class? I know that the receiver uses the pin …as i recall i think it was PIn number 3 .

For recording i used ARDUINO.

@ geduxadmin - I’ve posted a working example of SignalCapture on Codeshare:

https://www.ghielectronics.com/community/codeshare/entry/1007

Be aware that this code is written using NETMF 4.3, so it is possible there may be syntax differences between 4.2 and 4.3, but from a quick check, it appears that the constructor syntax is the same for SignalCapture in both 4.2 and 4.3.

As noted in the codeshare, if you’re using the GHI IR Receiver module, do not connect it in the Gadgeteer Designer, just use the constructor logic to map the correct socket, and pin number 3 (the signal pin for that module).

Given that your initial code appeared to have around 35 values to send, you should probably modify this line of code:



to use 35 instead of 100. As noted in the codeshare, I have experienced hangs in the program when the buffer is larger than the signal.

uint[] newCommand = new uint[] {869,795,1748,785,874,783,885,774,887,782,882,786,882,773,883,787,878,1573,891,769,1762,780,882};
No data captured.
No data captured.
Code for this command:
uint[] newCommand = new uint[] {845,811,1721,813,855,799,870,801,860,803,846,818,895,766,850,823,839,1614,862,801,1719,817,845};

This is what i’ve got.I’ve pressed the same button on Gadgeteerings GHI remote control

That looks like a reasonable result, in that the large vs. small values all appear in the same order each time. There’s always a bit of variation in the exact timings, though it seems a lot in this case.

If you want to check consistency across multiple runs, capture 20 or so times using the same button, and then average the numbers (if you copy them into Excel, it will be easy to average the values). The average should be pretty close to what the “target” value of the given command is.

I’d also try capturing some commands from your stereo remote now, and using the resulting output to try sending with the IR transmitter. And remember that you may need to try having the initial value (the first parameter to the SetBlocking call) false vs. true, and see if one or the other works.

This is what i’ve managed to get while reading Philips remote control ON OFF button.


Code for this command:
uint[] newCommand = new uint[] {2649,885,441,883,452,442,464,441,1336,1321,444,443,454,447,898,877,897,885,901,885,441,443,454,441,446,457,884,440,454,885,451,438,448,83147,2671,869,454,882,454,441,441,453,1332,1325,448,451,437,454,893,884,896,881,902,886,453,438,452,444,453,441,899,434,441,891,446,444,456};
Code for this command:
uint[] newCommand = new uint[] {2646,876,455,888,444,445,457,441,455,872,891,443,442,445,457,441,895,885,894,890,899,873,449,443,455,446,453,443,887,436,464,873,451,442,455,83137,2664,883,444,884,453,442,455,442,454,866,895,444,452,442,453,441,900,875,896,890,888,892,443,445,458,442,440,454,895,442,442,885,452,447,442};
Code for this command:
uint[] newCommand = new uint[] {2653,886,446,886,451,436,453,443,1337,1317,456,442,454,443,895,879,898,891,895,883,453,441,453,441,454,441,897,432,452,887,454,432,456};
Code for this command:
uint[] newCommand = new uint[] {2650,883,446,885,454,441,453,441,455,871,889,443,452,443,453,441,898,882,888,887,897,882,450,453,445,446,443,451,891,441,458,875,446,454,439,83142,2692,851,477,859,471,419,478,419,490,834,923,408,493,404,485,411,918,861,927,859,918,852,482,417,475,420,477,417,919,417,476,858,471,422,474};
Code for this command:
uint[] newCommand = new uint[] {2654,885,453,876,455,441,444,451,1337,1314,453,446,457,441,882,898,896,878,896,891,453,442,440,453,441,454,893,443,452,871,453,440,454,83135,2678,873,448,885,451,440,452,443,1346,1311,449,441,457,442,890,888,888,899,896,882,453,441,452,441,453,443,891,443,440,886,462,430,465};
Code for this command:
uint[] newCommand = new uint[] {2669,858,479,849,490,407,484,411,478,848,928,405,477,416,487,407,925,855,924,863,927,850,469,425,483,410,490,405,918,417,478,852,490,406,487,83097,2667,879,451,888,456,441,452,431,453,873,899,441,444,441,463,444,895,883,893,882,890,888,451,447,444,454,443,441,898,443,448,884,450,443,452};
Code for this command:
uint[] newCommand = new uint[] {2682,852,478,852,492,410,479,418,1351,1306,474,420,475,417,922,854,926,856,933,850,480,420,481,407,482,416,913,420,478,849,476,417,490,83100,2699,849,480,851,478,418,478,416,1369,1282,484,416,478,417,921,860,921,862,918,860,473,416,482,416,476,418,919,417,478,848,478,420,473,101243,165};
Code for this command:
uint[] newCommand = new uint[] {2622,855,476,848,491,406,490,409,484,842,919,417,474,420,478,410,922,863,913,861,922,866,475,419,477,417,465,430,916,407,489,849,478,413,476,83117,2693,851,477,850,484,410,487,412,479,852,910,418,472,422,477,416,924,851,921,864,923,860,478,417,479,407,482,420,921,405,483,861,477,417,470};
Code for this command:
uint[] newCommand = new uint[] {2686,847,478,864,479,418,477,406,1369,1291,488,411,477,411,932,855,925,851,918,861,480,420,482,416,474,420,915,418,480,849,470,420,476,83118,2688,853,475,862,473,419,488,406,1360,1291,487,411,455,440,898,887,886,897,888,889,451,442,441,454,453,443,882,445,458,873,460,440,446};
Code for this command:
uint[] newCommand = new uint[] {2649,886,443,890,457,436,455,442,450,878,892,439,452,441,451,443,896,889,884,899,891,882,454,442,450,443,456,438,894,443,453,884,451,438,454,83131,2692,848,487,852,478,421,480,406,489,834,927,406,490,405,490,406,933,852,920,858,916,860,481,421,473,413,479,417,925,409,487,847,477,417,480};
Code for this command:
uint[] newCommand = new uint[] {2662,873,448,891,441,443,451,442,1346,1320,451,445,441,454,894,886,889,892,893,880,454,443,455,444,452,443,891,431,453,884,457,442,455,83132,2685,855,478,852,494,406,477,417,1359,1300,476,418,476,418,921,865,912,863,918,856,475,425,478,417,477,417,923,407,479,861,465,430,474};
Code for this command:
uint[] newCommand = new uint[] {2656,885,449,884,441,453,440,454,441,882,894,441,438,454,454,434,890,890,902,882,896,889,451,442,454,442,452,443,890,443,452,873,453,441,453,83136,2700,843,491,848,479,406,485,417,477,848,911,422,479,412,478,419,917,863,924,853,929,855,487,408,485,409,477,418,929,405,479,857,470,421,481};
Code for this command:
uint[] newCommand = new uint[] {2662,874,447,884,453,433,458,442,1328,1325,454,444,454,441,898,878,895,888,900,884,455,434,454,444,455,442,899,430,444,889,457,432,458,83135,2692,851,476,861,482,406,490,405,1370,1297,477,409,478,416,924,865,919,853,934,848,474,418,477,418,489,406,919,412,479,854,479,424,485};
Code for this command:
uint[] newCommand = new uint[] {2650,886,440,886,452,442,453,448,443,874,890,453,440,454,443,443,901,887,890,885,898,884,444,443,465,441,453,430,897,436,454,884,452,441,451,83133,2693,861,474,855,480,417,477,416,479,843,918,419,484,411,478,407,936,853,915,861,915,860,489,417,471,419,478,417,922,404,489,852,468,419,477};
Code for this command:
uint[] newCommand = new uint[] {2655,880,451,873,453,441,454,445,1332,1326,446,453,441,456,888,890,891,885,892,888,456,442,455,432,459,433,905,431,453,889,455,433,452,83139,2660,884,441,893,454,433,455,445,1361,1301,477,408,483,419,918,858,921,854,924,865,473,422,470,421,471,425,923,411,479,849,478,420,478};
Code for this command:
uint[] newCommand = new uint[] {2652,888,451,875,465,440,442,441,454,871,905,441,450,432,454,441,897,886,900,884,890,886,445,455,440,445,451,444,895,440,452,883,454,441,442,83140,2706,850,474,852,481,418,479,417,476,848,922,411,466,430,477,416,909,869,922,852,931,849,489,405,484,419,477,419,915,418,477,851,474,417,482};
Code for this command:
uint[] newCommand = new uint[] {2652,886,451,875,456,444,453,442,1334,1318,453,450,452,443,891,888,886,896,894,876,458,441,454,464,426,468,874,433,453,878,450,443,457,83135,2671,873,457,875,452,442,453,441,1344,1325,454,430,454,441,893,893,896,888,886,883,454,441,451,443,454,441,896,440,454,882,451,441,454};
Code for this command:
uint[] newCommand = new uint[] {2653,884,453,878,443,453,442,453,442,883,896,436,443,454,452,441,885,890,898,883,900,885,454,441,442,452,440,455,895,429,453,883,458,443,442,83135,2679,869,452,885,451,441,451,444,452,871,894,441,454,441,441,454,888,885,906,876,902,885,452,441,450,443,452,443,895,432,461,881,454,441,441};
Code for this command:
uint[] newCommand = new uint[] {2658,872,464,872,451,440,456,440,1350,1308,453,442,452,538,803,892,891,877,901,888,449,443,458,431,454,441,906,428,454,877,458,441,448,83138,2658,890,440,885,465,430,452,443,1343,1321,457,441,440,454,890,888,891,892,895,875,452,445,459,443,453,430,891,443,452,885,454,447,454};
Code for this command:
uint[] newCommand = new uint[] {2655,884,440,884,455,441,461,432,452,883,889,442,454,443,440,455,891,884,887,887,897,885,454,446,456,442,453,441,888,445,441,883,464,432,451,83138,2661,887,446,886,453,442,452,442,453,872,889,443,454,442,451,443,895,885,888,896,896,875,453,441,454,441,455,444,894,442,441,888,446,443,459};
Code for this command:



@ geduxadmin - OK, so what happens when you take one or more of those and plug them into a program that is set up to send IR via the IR transmitter?

the module (devhammer module) LED’s blink,if i press the button event,they blink dark white kind of ,but they do blink it’s supposed to be like that ( I look thru my camera phone to verify that)

But my device does not recognize that a signal is coming.

If i press Power ON/OFF button with the original remote control - my stereo turns ON/OFF
If i press Power ON/OFF button on a remote that was given from GHI with the IR RECEIVER , my device also indicates,that a signal is coming (it flashes an indicator in the screen) but it does nothing (It’s supposed to be like that because the GHI remote uses RC5 and the Phillips uses a different protocol)

But if i try to send out the code via devhammer module the device just does not even recognize that I’m trying to send a signal.

Have any ideas? I’m also using the 940nm LED’s

I think of trying today to paste a random signal to an array and with button events try to read the signal with (GHI Receiver) and send it with devhammer module) I think if i get the same signal that I sended the module really works and there is something with the LED’s on the remote perhaps.

But then why my device notices the GHI Remote control when i press various buttons?

It’s so strange

I have managed to write a program that

Takes the signal that is pasted in the array in the top of the code

 { 2680, 840, 460, 840, 460, 420, 460, 400, 480, 840, 900, 400, 460, 420, 460, 420, 900, 840, 900, 840, 900, 860, 460, 420, 460, 400, 480, 400, 900, 420, 460, 840, 460, 400, 480 };
  [
```cs]/code


And it is trying to send that  to the receiver ( I press 1 button to receive a command and then very fast while it is waiting i press the second button to send the command.)

The Receiver says "No data captured" if i press something via remote control it does capture data.If i send data via transmitter it says "No data captured" 

Do you have any ideas? 

I paste the code bellow


```cs
 
using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.Petkus;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Premium.Hardware;
using Gadgeteer;
using Microsoft.SPOT.Hardware;
using System.Text;






namespace IRLED
{
    public partial class Program
    {

        SignalCapture irSignal;
        static SignalGenerator irSigGen;
        static uint[] buffer = new uint[] { 2680, 840, 460, 840, 460, 420, 460, 400, 480, 840, 900, 400, 460, 420, 460, 420, 900, 840, 900, 840, 900, 860, 460, 420, 460, 400, 480, 400, 900, 420, 460, 840, 460, 400, 480 };
        uint[] signal = new uint[200];
       

        void ProgramStarted()
        {
            Debug.Print("Program Started");
            
            KAIRINIS.ButtonPressed += button_ButtonPressed2;
            irSignal = new SignalCapture(Socket.GetSocket(5, false, null, null).CpuPins[3], Microsoft.SPOT.Hardware.Port.ResistorMode.Disabled);
            
            DESININIS.ButtonPressed += button_ButtonPressed;
            Socket socket = Socket.GetSocket(4, false, null, "X"); // null?
            irSigGen = new SignalGenerator(Socket.GetSocket(4, false, null, null).CpuPins[5], true,35);

            Debug.Print("Signal sent");
        }




        void button_ButtonPressed2(Gadgeteer.Modules.GHIElectronics.Button sender, Gadgeteer.Modules.GHIElectronics.Button.ButtonState state)
        {
           
            KAIRINIS.TurnLEDOn();
    
            int edges = irSignal.Read(false, signal, 0, 35,1000);
            if (edges == 0)
            {
                Debug.Print("No data captured.");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Code for this command:");
                sb.Append("uint[] buffer = new uint[] {");
                for (int i = 0; i < edges; i++)
                {
                    if (signal[i] > 0)
                    {
                        sb.Append(signal[i].ToString());
                        if (i < (edges - 1))
                        {
                            sb.Append(",");
                        }
                    }
                }
                sb.Append("};");

                Debug.Print(sb.ToString());
            }
            KAIRINIS.TurnLEDOff();
        }

        void button_ButtonPressed(GTM.GHIElectronics.Button sender, GTM.GHIElectronics.Button.ButtonState state)
        {

            DESININIS.TurnLEDOn();

            Debug.Print("Program Started");

            irSigGen.SetBlocking(true, buffer, 0, buffer.Length, 1000, true, 38000); 

            Debug.Print("Program died");
            DESININIS.TurnLEDOff();

        }



    }
}
[
```cs]/code

@ geduxadmin - Please fix your code tag (edit the post and remove the extra code tag embedded at the end).

Two more things:

  1. While pointing a camera at your IR LED module can tell you if the LEDs are turning on, it’s not useful for anything beyond that. To tell if the IR LED is sending what it should be sending, you would need to use an oscilloscope to test the output. See my earlier post for a link to a program that you can use to do this cheaply.

  2. Another potential way to test is to set your program up so that when you press the button, it prepares to record signal via SignalCapture, but with a second button sends the previously stored command via the IR transmitter module. Then you could press the first button, point the IR transmitter at the IR receiver, and press the second button. Then you just check whether the received command matches what you sent (within reason…the exact timings are apt to be subtly different.

EDIT: Actually, after thinking about it and running a quick test, the 2nd suggestion above won’t work with a single board, because the Read method on SignalCapture is blocking, and won’t return until either it’s read the full buffer amount, or until the ReadTimeout expires (if set). So in order to test the IR transmitter by recording the pulses, you’d need a second mainboard set up to do the capture.

Will do so.I will fix code later on.

I have tested the module with oscilogoroph.Connected both the transmitter and fhe receiver.Everything works perfectlly fine.I think something is wrong with my code.Or carrier frequency.I don’t know what exact frequency GHI IR Receiver uses…38000 hz?

Problem solved.Module works.It was the wrong carrier frequency that was messing everything up i have made up a loop and tested it out.Made a video.I will upload it to youtube later on.

Have a great day.Thank you for your support.

You helped me a lot !:slight_smile: