Notes About Working with Various Arduino & Netduino Microcontroller Boards

Saturday, June 9, 2012

Arduino Leonardo: Serial versus Serial1

Today I received the Parallax RFID reader that I had ordered. I decided to give it a quick test with my Arduino Leonardo. I took the sample code from the Arduino Playground (Code for Using the Arduino with the Parallax RFID Reader), but found that it didn't work. The code works fine on my Arduino Uno, but not on the Leonardo. 

The Arduino Serial Reference page held the key: Serial is for accessing the USB connection between the Leonardo and the IDE serial monitor. For serial communications via digital pins 0 and 1, use Serial1

I had read that the Leonardo had separated USB and serial communications, but I hadn't translated that into real-world practice. Obviously, this issue will come up with any code using serial communication with anything other than the serial monitor in the IDE.

While on the subject of serial ports and the Leonardo, I note that the connection between the IDE and the Leonardo was not very stable when I used one of the USB ports on my monitor. I kept getting memory buffer errors when trying to upload sketches and the Serial Port option on the Tools menu stopped showing the serial port that I had previously chosen. Using a USB port on the computer itself resolved this issue.

No comments:

Post a Comment