2

I am sending three signals from one Arduino mega to another using xbees. On the receiving end I am using these signals in a Simulink code to control servo motors. Currently it is set up to read from analog pins without the wireless set up. With the wireless technology the signals are all being sent and received through one serial port. I believe I would need to change the inputs in Simulink to a serial receive block instead of an analog pin block. The problem is the documentation for the serial receive block says you can not assign more than one serial receive block to the same serial port. If anyone has a solution to this it would be greatly appreciated!

receiving code

int received1; 
int received2;  
int received3;  
void setup() {  
  Serial.begin(9600);  
}  
void loop() {  
  if(Serial.available() )  
  {  
    received1, received2, received3 = Serial.read();  
  }  
}   

transmitting code:

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
  Serial.write(sensorValue1, sensorValue2, sensorValue3);
  delay(1);       
}
  • How are the three signals encoded in the bitstream? – Ignacio Vazquez-Abrams Mar 24 '14 at 1:35
  • Here is my receiving end arduino code. Not sure if its correct yet. I will add it to the question. – user734 Mar 24 '14 at 2:44
  • What does your sending code look like? – Ignacio Vazquez-Abrams Mar 24 '14 at 3:15
  • I will add that to the question as well – user734 Mar 24 '14 at 4:07
  • What is the result shown on the serial monitor? Let the three values received on the receiver code be shown on the serial monitor. Tell us exactly what do you have? Is it a trash? or nothing is received? – Adel Bibi Mar 24 '14 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.