My goal is to communicate serially with a GPS unit. using the Arduino with the RS232 shield from CuteDigi (http://www.cutedigi.com/product_info.php?products_id=4329). Schematic found at CuteDigi: (http://www.cutedigi.com/pub/Arduino/arduino_RS232.pdf) Before attaching a GPS device, I decided to test out serial communiation using the RS232 shield.
Here are the steps I've gone through so far and the results:
- First, I ran the following script WITHOUT the CuteDigi RS232 shield.
/*
SoftwareSerial example
Sample of the SoftwareSerial library. Listens for serial in on pin 2
and sends it out again on pin 3.
by Tom Igoe
based on examples by David Mellis and Heather Dewey-Hagborg
written: 6 Jan 2007
*/
// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>
#define rxPin 0
#define txPin 1
#define ledPin 13
// set up a new serial port
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
byte pinState = 0;
void setup() {
// define pin modes for tx, rx, led pins:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
pinMode(ledPin, OUTPUT);
// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}
void loop() {
// listen for new serial coming in:
char someChar = mySerial.read();
// print out the character:
mySerial.print(someChar);
// toggle an LED just so you see the thing's alive.
// this LED will go on with every OTHER character received:
toggle(13);
}
void toggle(int pinNum) {
// set the LED pin using the pinState variable:
digitalWrite(pinNum, pinState);
// if pinState = 0, set it to 1, and vice versa:
pinState = !pinState;
}
RESULT 1: everything works great! Characters typed in the Serial Monitor were echoed as designed.
- This time I used the same sketch and the RS232 CuteDigi shield attached.
RESULT 2: With the RS232 shield attached, the program encounters problems uploading the sketch with following error code:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
If I first upload the sketch to the Arduino without the RS232 shield, disconnect the USB cable, attach the RS232 shield, now using the DB9 port of the shield, the program does not work as designed (I'm attempting to communicate in this configuration with the Arduino using TeraTerm Pro).
This is my first attempt at using an RS232 shield, so I'm a newbie in that respect.
Any help/guidance would be greatly appreciated.
Thanks in advace, Gerald (N4PAX)