Go Down

Topic: APC 220 wireless tx\rx (Read 2635 times) previous topic - next topic

ThunderWiring

hello,

im working on a wireless robot that uses the APC220 wireless module for communication between a controller(joystick)
and the robot.

usually, one module is used as a receiver and another module  as a transmitter.

my question is, is it possible to use each one as a receiver and a transmitter at the same time.
because i need to send commands from a controller to the robot, and the robot should send data back.

i made 2 methods on both the robot and the controller: one that reads(Serial.read() ) and another for sending (Serial.write() )
and it didn't work. what should be done if it's possible?
Regards,
ThunderWiring

groundFungus

I have used the APC 220 for various projects.  It works very well and is easy to use.  Did you set up the baud rates using the ACP22X program?  You need to set both up and they need to be set the same.  Are your baud rates in the sketch and Serial Monitor the same as set up in the ACP22X program.  Without being able to see your code you force us to guess at what your problem(s) may be.  So, please post your code (in code tags, the # above).

ThunderWiring

thanks for reply!

i have them work fine, as the rx receives data from the tx.
but, the question is, how can i make the tx RECEIVE from the rx? is that even possible to implement?

code for rx:
NOTE: the values of the received/transmitted bytes are determined by other functions in the code that the loop() calls them up, but they are irrelevant for this issue, so i didnt include them

Code: [Select]

byte TXdata = 0, RXdata = 0;
void setup()
{
     Serial.begin(9600);
     /*variables and pinModes*/
}
//************************************************************
//------------------------------------------------------------
void loop()
{
     RX();
     delay(100);
    TX();
    delay(100);
}
//************************************************************
//------------------------------------------------------------
void RX()

  if(Serial.available()>=1)
  {     
    RXdata = Serial.read();
    Serial.flush();       
    return;   
  }
}
//************************************************************
//------------------------------------------------------------
void TX()

  Serial.write(TXdata);
  Serial.flush();
  return;
}


code for tx:
Code: [Select]

byte tx = 0, rx  = 0;
void setup()
{
     Serial.begin(9600);
     /*variables and pinModes*/
}
//************************************************************
//------------------------------------------------------------
void loop()
{
     receive();
     delay(100);
    transmitt();
    delay(100);
}
//************************************************************
//------------------------------------------------------------
void receive()

  if(Serial.available()>=1)
  {     
    rx= Serial.read();
    Serial.flush();       
    return;   
  }
}
//************************************************************
//------------------------------------------------------------
void transmitt()

  Serial.write(tx);
  Serial.flush();
}code]
Regards,
ThunderWiring

groundFungus

Are you sending data (tx) from the Serial Monitor to the Arduino (rx) ? 

ThunderWiring

no, i dont use the serial monitor at all, the communication is straight between 2 arduinos
Regards,
ThunderWiring

Go Up