RS-232 Test on M-Duino PLUS

RS-232 Test on M-Duino PLUS

In this post it is showed how to test the RS-232 M-Duino PLUS version.

Connecting an M-Duino with other equipment through RS-232. On the code is showed that you must send a 0xA5 thought RS-232 to complete this test.

Next is showed the code:

/////////////////////////////////////////////////////////////////////////////
void setup() {
  Serial.begin(9600L);
  Serial.println("mduino-plus test RS-232 started");
  Serial2.begin(9600L);
}
/////////////////////////////////////////////////////////////////////////////
void loop() {
  while (Serial2.available()) {
    Serial2.read();
  }
  Serial2.write(0xa5);
  
  delay(50);
  
  if (Serial2.read() == 0xa5) {
    Serial.println("RS232 (Serial2) OK");
  } else {
    Serial.println("RS232 (Serial2) FAIL");
  }
  
  delay(1000);
}
Los comentarios están cerrados