Facing problem with IR and bluetoth commuication with arduino

hello guys,

I've problem in using bluetooth and IR transmitter at same time with arduino uno. Please refer bellow block diagram for more clarification. I'm using arduino uno as intermediate device for communication between bluetooth transmitter and IR receiver.

Every time when I receive data via bluetooth then according received data I need to send command to motor for changing it's speed via IR transmitter.

Now problem is that every time before sending data using IR transmitter, I must have to end bluetooth communication (i.e. softwareserial.end() ) and again begin it after completion of IR transmission. Is there any other way to do this communication without changing status of bluetooth communication? Because motor just run once per program loop. So if my bluetooth transmission took 500ms then motor will stop for rest 500ms.

Flow of program is as described bellow.

  1. Reading data from bluetooth device (This contain lots of bytes and this process takes almost 500ms)
  2. ending bluetooth communication
  3. Manipulating received data
  4. Send data to motor using IR
  5. Restart bluetooth communication

So you can see that motor runs for few ms in every 500ms. So i am not able to get continuous motion.

Please help me out.....

thanks in advance

According to your block diagram you have a "Motor" that is controlled directly by infrared. I've never heard of such a thing.

You also have an "Intermediate device", apparently a UNO, that receives "lots of bytes" from bluetooth and emits some sort of IR signal.

But you haven't said what components are used for bluetooth or IR, how any of these things are connected or powered. And critically you haven't posted any program.

A component list with datasheets, a circuit diagram and a program listing would be good. Currently I can't see anything to help with.

Steve

Of course motor side also have arduino uno as well IR receiver.

I'm simply using 9V battery for power up both arduino.

Here is my code

#include <SoftwareSerial.h>
#include <IRremote.h>

#define BAUDRATE 9600
#define MAX_Dist 128

byte Packet[MAX_Dist] = {0};
byte Checksum = 0, Calculated_Checksum = 0, Current_Read, Previous_Read , Connection_Check;

int Dist;

int IR_Pin = 3;

unsigned int Motor_Forward[] = {5700, 5700, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550};

unsigned int Motor_Reverse[] = {5700, 5700, 500, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 550, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550};

unsigned int Motor_Stop[] = {5700, 5700, 550, 550, 550, 1700, 550, 1770, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550};

SoftwareSerial ss(10, 11);
IRsend irsend;

byte Read_One_Byte()
{
  int i = 0;
  int Temp_Byte;
  while (!ss.available())
  {
    i++;
    if (i > 10000)
    {
      irsend.sendRaw(Motor_Stop, sizeof(Motor_Stop) / sizeof(int), 38);
    }
  }
  Temp_Byte = ss.read();
  return Temp_Byte;
}

void setup()
{
  ss.begin(BAUDRATE);
  Serial.begin(BAUDRATE);
  pinMode (IR_Pin, OUTPUT);  //output of IR as used in library
}

void loop()
{
  if (Read_One_Byte() == 255)
  {
    if (Read_One_Byte() == 255)
    {
      Dist = Read_One_Byte();
      if (Dist == MAX_Dist)
      {
        Calculated_Checksum = 0;
        for (int i = 0; i < Dist; i++)
        {
          Packet[i] = Read_One_Byte();
          Calculated_Checksum += Packet[i] ;
        }
        Calculated_Checksum = 255 - Calculated_Checksum;
        Checksum = Read_One_Byte();
        ss.end();
        if (Checksum == Calculated_Checksum)
        {
          Connection_Check = Packet[0];
          if (Connection_Check == 64)
          {
            Current_Read = Packet[98];
            if (Current_Read >= Previous_Read)
            {
              irsend.sendRaw(Motor_Forward, sizeof(Motor_Forward) / sizeof(int), 38);
            }
            else
            {
              irsend.sendRaw(Motor_Reverse, sizeof(Motor_Reverse) / sizeof(int), 38);
            }
            Previous_Read = Current_Read;
          }
          else
          {
            Serial.println("Re_Connect device");
            irsend.sendRaw(Motor_Stop, sizeof(Motor_Stop) / sizeof(int), 38);
            Current_Read = 0;
          }
          ss.begin(BAUDRATE);
        }
      }
    }
  }
}

and for bluetooth communication, I've HC-05 bluetooth module in masted mode(one use in intermediate device).