HELP ME.. how to send ascii data(RS 232 frame) via IR without Serial intructrio


i want to send ascii data from pin 11 in arduino 1 to pin 12 in arduino 2 via IR. i use TSOP 1838 to receive data. i really don’t want to use Serial intruction for send and receive data like Serial.print(), Serial.available(),, etc. i only use Serial to show the result on my Serial monitor.

i use ASK modulation. so bit “0” is IR signal with 38khz frequency. and bit “1” is other signal. in this case i use continuous “1” signal.

i send ascii for “E” the binary is 0100 0101.
i send bit from LSB to MSB bit first, that is 1010 0010
i received LSB bit first. so i have to invert the sequence.

i use 300 bps data rate
and 9600 baud for show result to serial monitor.

the code is attached.

but i don’t receive data correctly.
in few time, even though no start bit, the recipient has stated that the bit has started. so data is broken etc.
other problem is i see in serial monitor that 3 bit “0”, interpreted as 4 bit “0” or “001”. etc.
help me find the wrong code or wrong timing.
thanks before…

Sender.ino (706 Bytes)

receiver.ino (1.51 KB)

Signal spektrum.png

Don’t attach small codes, we can’t read them on mobile phone easily. Just put the code directly in your post using the code tags (read how to use the forum)

Have you looked at / are you using the IRremote Library ?

Your sender code shows no attempt to transmit a specific character sequence:

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:
  kirim0();   // start bit

  kirim1();   // data 0
  kirim0();   // data 1
  kirim1();   // data 2
  kirim0();   // data 3
  kirim0();   // data 4
  kirim0();   // data 5
  kirim1();   // data 6
  kirim0();   // data 7

  kirim1();   // stop bit
  delay(5000);  // delay data transfer
void kirim1(){
void kirim0(){
  for (int i=0; i<=127; i++){     // 128*26 = 3.33mS

It looks like you are sending eight 128 cycle bursts of a 38kHz carrier.
Usually, you do this by defining a timer at 38kHz and modulating that.
Have you looked at the data sheet for the device to ensure that the bursts you are sending are within spec for the device . The delay() function takes an integer argument.

This IR Serial Thread may help.