IRremote library how to send customized Protocol

Hi, I am trying to use the IRremote library to send some customized signals through the transmitter, and I am not too sure on how to go about doing that.

So for example, in the line: "IrSender.sendNEC(sAddress, sCommand, sRepeats);" if I wanted to send a single bit of 1 or 0, how should I go about doing that?
When I put 0x1 for sAddress, the receiver is unable to decode it

Secondly, I am not quite sure what sCommand does exactly, so I would also like some clarifications.
I found the IRremote repository https://github.com/Arduino-IRremote/Arduino-IRremote here, but I am still a bit unclear, so any help would be greatly appreciated.

Why is the customization important? What are you actually doing? I ask because the way you're expecting to do it, probably will never work...

Also, what receiver? It matters.

send one code representing a zero and a 2nd code for one?

example, channel-up and channel-down

Sorry for not clarifying, this is my IR module here

All I wanted to do is send binary bit of just 1 or 0 through my IR transmitter and have my IR receiver identify it as either being 1 or 0

Yes, exactly that, but I need to incorporate the IRremote library because I am using the IR transceiver module

This is the IR module I have

You've been handed the solution in reply #3, unless this is an academic assignment that you've been handed (which can only be done a certain way for marks).

Also you never told us what this is for. It would help us understand and therefore help.

Technically you don't need any library to send individual bits via IR. You do need to generate 38kHz on one of the pins and turn it on and off. You can write code to do that, realistically you would have to use a hardware timer for that.

The receivers only passively detect the presence or absence of 38kHz signal. If you want to "identify" it, you would have to do it in your code. The IR library does that, but it's designed to process handheld remote signals exclusively. It is not designed for general purpose experimentation with IR.

The receiver is looking for an IR signal modulated with a carrier frequency of about 38 kHz. You can create pulses of various lengths with:

  for (int i = 0; i < length; i++)
  {
    digitalWrite(pin, LOW);
    delayMicroseconds(9);
    digitalWrite(pin, HIGH);
    delayMicroseconds(9);
  }

Experiment with your sender and receiver to see how short a pulse-train the receiver can detect. Then you know the shortest pulse you can send. You could use a 'short' pulse for 0 and a 'long' pulse for 1. You will need to insert some minimum space between the 0 and 1 bits so the receiver can tell the pulses apart.

I said, "realistically" because although you can generate pulses easily as above, it won't survive integration into most larger programs intended to perform other tasks as well. Perhaps that is not important to you, I guess we'll never know...

If the overhead of using software to generate the 38 kHz carrier is too much for your program, you can use a timer to generate it in hardware and turn it on and off whenever you want.

This is for a research project.
Yes the main reason I started using IRremote is because it can generate the 38kHz, and I find that easier than if I were to try generating it myself.

I see, so does that mean it will be hard to try to send my own customized signals?

I see, sorry if I am not understanding, but why is the delay 9 microseconds for 38kHz?

Well for the most part, I will just be having multiple transmitters and receivers that will send signals to one another, and so correlation is also another thing I have to consider

One cycle of 38 kHz takes 1/38000 seconds. That's about 26 microseconds but the instructions outside of delayMicroseconds() also take time, leaving about 18 microseconds of delay needed, split into HIGH and LOW half cycles.

It completely depends on the requirements of the project you haven't told us anything about.

I see, would that change if I have more code that needed to be run? Does that mean I would have to do some more tests myself?

It is simply just sending some binary bits of one's or zero's, then have the receiver recognize it as one's or zero's

No. Just run the loop the number of cycles you want to send a pulse. You can send pulses of different lengths to send 0 and 1 bits.

void Send38kHz(unsigned milliseconds);
{
  // 38 kHz is 38 cycles per millisecond
  unsigned cycles = milliseconds * 38;

  for (unsigned i = 0; i < cycles; i++)
  {
    digitalWrite(IROutputPin, LOW);
    delayMicroseconds(9);
    digitalWrite(IROutputPin, HIGH);
    delayMicroseconds(9);
  }
}

void SendZero()
{
  Send38kHz(1);
  Delay(1);
}

void SendOne()
{
  Send38kHz(2);
  delay(1);
}
void loop()
{
  unsigned long duration = pulseIn(IRInputPin, HIGH, 4000);

  if (duration >= 900 && duration <= 1100)
  {
    Serial.print('0');
  }
  
  if (duration >= 1900 && duration <= 2100)
  {
    Serial.print('1');
  }
}

You probably mean synchronization. Keep in mind, most systems with both a transmitter and receiver can not both transmit and receive simultaneously.

Also, the received signal strength varies, and most receivers have AGC to handle that (Automatic Gain Control), so in the IR protocol used in remotes, the actual data is preceded by a series of AGC training pulses to allow the AGC to settle before decoding begins. The effect without it, is that a raw pulse (off/on/off) will have different pulse length under different receive conditions.