Tuesday, February 22, 2011

Software Serial on Arduino for Debugging and Displaying Serial Data in a Terminal Window

In order to debug the code for my remote car starter project I wanted to be able to output information via serial to display on my computer. Unfortunately the Arduino Uno has only one hardware serial port which was already in use to communicate with the Motorola c168i. To solve this problem I used a TTL serial to USB cable connected to a standard I/O pin on the Arduino. I then used the software serial library to output the data.

The Arduino IDK has a serial monitor tool built in but I would have had to change the selected serial port back and forth from one port to another to program or view the debugging data. To get around this I just used terminal to display the data.

Below is the Arduino sketch used in the example.
#include <softwareserial.h>
#define rxPin 2
#define txPin 3
int count = 1; 
SoftwareSerial PCserial = SoftwareSerial(rxPin, txPin); 
void setup() { 
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
void loop() { 
PCserial.println("This is output via software serial.");
PCserial.print("Count: ");

1 comment:

  1. Interesting. I came across your other post that involved using the cell phone over serial to send sms. I too am trying to use the same motorola to send sms over serial. I have been somewhat successful, but the sms only goes through occasionally, I am unsure why. If you have any advice, please pm me. Thanks!