You can make the serial port run in inverted mode. For a previous person I posted the following snippet as a way to do what they wanted:
#include "USARTClass.h"
Usart *_pUsart;
void setup() {
// put your setup code here, to run once:
_pUsart = USART0; //USART0 is Serial1, change this for other serial ports
_pUsart->US_MR = US_MR_USART_MODE_RS485 | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_EVEN |
US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL;
}
void loop() {
// put your main code here, to run repeatedly:
}
You can do the same thing. You need to set inverted mode in your mode call and you probably don't want many of the other options that that user needed. But, you could do this:
_pUsart->US_MR = US_MR_USART_MODE_NORMAL | US_MR_USCLKS_MCK | US_MR_CHRL_8_BIT | US_MR_PAR_NO |
US_MR_NBSTOP_1_BIT | US_MR_CHMODE_NORMAL | US_MR_INVDATA;
All of these mode setting definitions are found in arduino/sam/system/CMSIS/Device/ATMEL/sam3xa/include/component/component_usart.h
And, remember, all that code was setting the mode for Serial1. If you aren't using Serial1 then you will need to that _pUsart = line. Serial is NOT a USART but rather a UART and the mode definitions are probably different. You should still be able to do the same basic thing but you'll have to look up the mode bits.