I am trying to troubleshoot a Software Uart Connection from my Arduino Nano, and I do not understand this output. The setup is simple, I have a Software Serial connection on pins 2 and 3. I send 170, which I expect to be 10101010 of course with a low start bit and high stop bit.
I hook up to the TX line with my Oscope and check the waveform, but its not as I expect.... I only see 101010
#include <Arduino.h>
#include <SoftwareSerial.h>
#define SW_RX 2
#define SW_TX 3
#define SW_BAUD 9600
SoftwareSerial Serial2(SW_RX,SW_TX);
void setup(){
Serial2.begin(SW_BAUD);
delay(1000);
}
void loop(){
Serial2.write(170);
delay(100);
}
Can someone help me to understand this output?
-
1it is helpful if you start thinking in hex because the conversion to binary is direct, without any math ... you sent 0xAA ... try 0x55 ... 0x40 ... 0x02 ... what do these values reveal about the problem you are trying to solve?jsotola– jsotola2022年11月04日 23:42:54 +00:00Commented Nov 4, 2022 at 23:42
1 Answer 1
It is working exactly as expected. The scope trace shows 10010101011:
- 1: idle state of the serial port
- 0: start bit
- 0: first data bit
- 1010101: other data bits
- 1: stop bit.
Keep in mind that the data bits are sent least-significant first.