Serial pin question..

Pin 0->RX, pin 1->TX So.. how does this work? When I do a Serial.println("something"); does it concurrently toggle pin 1 with the shifted bits of this message? And.. if I toggle pin 0, will it show up as data as in Serial.available();?

-jim lee

Yes, it's just the pin toggling HIGH and LOW with the right timing.

A nice tool for exploring digital signals is a logic analyzer. Last I checked, you could get an 8 channel 24 MHz logic analyzer on eBay for around $7 (maybe gone up a bit since then due to the world going crazy in the last year) that is well supported by the free open source sigrok Pulseview software. You can connect one to your Arduino boards serial pins, then take a snapshot of the digital states of those pins over a period of time, and even plug that data into a decoder that will translate it into the text you were printing. Of course, you can spend more to get a much nicer logic analyzer, but it's pretty cool that this sort of technology is so accessible. I don't use it enough to justify spending hundreds of dollars on a high end logic analyzer, but when I do end up using it, it's super handy to have. Not something you could do with an LED!

When the hardware USART is enabled, it overrides normal PORT I/O functionality for PD0 and PD1. See Section 20 of the ATmega328P Datasheet.

OK.. "When the hardware USART is enabled" Is how to enable this in the online IDE reference doc? I've never found it. I understand you can enable it using a PORT I/O function. But how does it get enabled using the old setup() / loop() c++ stuff?

-jim lee

jimLee: OK.. "When the hardware USART is enabled" Is how to enable this in the online IDE reference doc? I've never found it.

Probably because the Arduino core and HardwareSerial class handles the USART for you.

I understand you can enable it using a PORT I/O function. But how does it get enabled using the old setup() / loop() c++ stuff?

You can access the USART registers with C++ code. Take a look at the source code for HardwareSerial. It's written in C++.

In Arduino-land you enable the UART with "Serial.begin(baudrate);",

johnwasser: In Arduino-land you enable the UART with "Serial.begin(baudrate);",

Which is implemented (in C++) by the HardwareSerial class.

johnwasser: In Arduino-land you enable the UART with "Serial.begin(baudrate);",

So.. when I'm talking to the serial monitor, pin0 & pin1 are toggling as well?

-jim lee

jimLee: So.. when I'm talking to the serial monitor, pin0 & pin1 are toggling as well?

-jim lee

Yes. Try this - jumper the RESET pin to ground. Connect pin 0 to pin 1. See the echo in the serial monitor as you type.

Haha! Good idea. But I'll take your word for it.

Thanks everyone! I really appreciate the info.

-jim lee