rs485

Posted by Mirkoelettronics on Thu 01 Oct 2015 08:20 AM — 2 posts, 15,635 views.

#0
hello, I tried to use the code rolling master tutorial on ommunication RS485 but communication is unique between two devices.
I tried to differentiate the codes, in id 0:

 // make our LED match the switch of the previous device in sequence
  if (message.address == (myAddress - 1))
    
   
    digitalWrite (LED_PIN11, message.switches [2]); // not run, or not recive**********************

  digitalWrite (OK_PIN, LOW);
  } // end of processMessage

// Here to send our own message
void sendMessage ()
  {
  digitalWrite (SEND_PIN, HIGH);
  memset (&message, 0, sizeof message);
  message.address = myAddress;

  // fill in other stuff here (eg. switch positions, analog reads, etc.)

  message.switches [0] = digitalRead (SWITCH_PINa0); // t's ok  *******
  message.switches [3] = digitalRead (SWITCH_PINa1); // t's ok ********


and id 1:


 // make our LED match the switch of the previous device in sequence
  if (message.address == (myAddress - 1))
    digitalWrite (LED_PIN13, message.switches [3]); // ok  to recive ****************
    digitalWrite (LED_PIN12, message.switches [0]); // ok to recive ****************
    

  digitalWrite (OK_PIN, LOW);
  } // end of processMessage

// Here to send our own message
void sendMessage ()
  {
  digitalWrite (SEND_PIN, HIGH);
  memset (&message, 0, sizeof message);
  message.address = myAddress;

  // fill in other stuff here (eg. switch positions, analog reads, etc.)

 
 
  message.switches [2] = digitalRead (SWITCH_PINa2); // no send this message *****************************************




Amended on Thu 01 Oct 2015 08:32 AM by Mirkoelettronics
Australia Forum Administrator #1
Template:Arduino
Please post Arduino-related questions to the Arduino Forum or to StackExchange: Arduino. This saves splitting questions and answers between this forum and the Arduino ones.