Serial Monitor VS Serial Output

Ok, I’m very new to the Arduino and I hope this isn’t too stupid a question. I have a Duemilanove and a very simple project. I need the Arduino to sense a contact closure and transmit one or another ASCII string depending on the state of the closure. Just about the simplest project possible. I’ve got the sketch built and it does what it is supposed to do. If I monitor the serial output with Serial Monitor I get the string correctly ABCDE is ABCDE and FGHIJ is FGHIJ. However when I monitor Pins 0 and 1 I get _¯ÝÕ?ë and ®½µ­?ë in the text field of my RS232 monitor running on the PC.

What is going on? What am I doing wrong?

Here is the sketch. It’s copied directly from one of the tutorials.

/*

  • Alternating switch
    */

int switchPin = 2; // switch is connected to pin 2
int val; // variable for reading the pin status
int buttonState; // variable to hold the last button state

void setup() {
pinMode(switchPin, INPUT); // Set the switch pin as input

Serial.begin(9600); // Set up serial communication at 9600bps
buttonState = digitalRead(switchPin); // read the initial state
}

void loop(){
val = digitalRead(switchPin); // read input value and store it in val

if (val != buttonState) { // the button state has changed!
if (val == LOW) { // check if the button is pressed
Serial.println(“ABCDE”);
} else { // the button is -not- pressed…
Serial.println(“FGHIJ”);
}
}

buttonState = val; // save the new state in our variable
}

Is the monitor set for the correct baud rate?

and is it expecting TTL levels vs RS232?

It is set for the correct baud rate however it is expecting RS-232 and not TTL. Which thanks to bill2009 and re-reading the spec page I now realize that that is what Pins 0 and 1 are sending. Now I need to read up on how to actually get RS-232 out of the board.
Thanks.

Now I need to read up on how to actually get RS-232 out of the board.

A MAX232 RS-232 to TTL IC converter chip with a few caps is a popular choice. Here is a module I bought recently that works well.

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&ssPageName=STRK:MEWNX:IT&item=260429650261

I’ll try it.
Thanks!

what IS the RS232 monitor and does it have any options?

I’m monitoring the output of the Arduino Pins 0 and 1 with a cable plugged into the serial port of the PC. The software I’m using is called User Specification protocol2 Tool ver 1.0.23 from TVone.com.
I’m monitoring it for debugging purposes.

I’m trying to trigger a TVone C2-2355a via it’s RS-232 port. I have the text string for the action I want the C2-2355a to perform and I want the Arduino to send that string when it senses a contact closure.

It doesn’t work because the Arduino isn’t outputing RS-232.
The MAX232 module should fix that, right?

what IS the RS232 monitor and does it have any options?

If you mean what is the Arduino serial monitor, it is a built in function of the Arduino IDE that allows one to send and receive serial data from a serial port. It is only RS-232 if you have a RS-232 serial port avalible on your PC and have selected it from the IDE, otherwise it can be used to send and receive serial data through a USB serial port if also avalible and selected from the IDE. This serial monitor has a baud rate selection menu. One can also utilize any standalone PC based serial terminal program to perform the same function (with lots of additional capablilites, options and features. Hyperterminal is one well know windows based serial terminal program but there are many others avalible also. I like to use Bray-terminal:

http://braypp.googlepages.com/terminal

Lefty

I like that Bray-terminal and thanks again for the help.
For some reason I thought that the duemialnove had a RS-232 port built in. I know it has the FTDI but I don’t think that helps me.

I know it has the FTDI but I don’t think that helps me.

That is correct, the FTDI chip is a USB to TTL serial convertor chip. It cannot correctly send or receiver at RS-232 voltages. There are Arduino clone boards that use a MAX232 RS-232 convertor chip instead of the FTDI chip avalible. Here is one I bought when I first got started using the Arduino system:

http://nkcelectronics.com/freeduino-serial-v20-board-kit-arduino-diecimila-compatib20.html

Lefty

That’s cool. This was supposed to be a quick “bang it together” project but it hasn’t turned out that way. That’s what I get for trying to be fancy and get the “better” one. That serial Freeduino looks perfect. Maybe next time.

Ok, so now that I’m back from vacation and my Max232 has arrived I’m still having problems.

I have everything setup so that the Arduino sends a text string via the MAX232 to the scaler but the scaler is still not responding.
I think it’s a syntax problem. When I use Serial.print the string is sent without a when I use Serial.println a and a are appended. TVOne doesn’t want the .

No flow control is used - however all control packets start with an ASCII ‘F’, end with
carriage-return (13 decimal, 0x0D hexadecimal) and all such packets sent to the unit will
be acknowledged (thereby provided software handshaking). Note that a line-feed (LF)
should not be sent.

How do I send a with Serial.print or how do I stop Serial.println from sending the ?

I know this is a simple question but I looked and can’t find an answer.
Thanks.

How do I send a with Serial.print

Serial.print(13,BYTE);

or

Serial.print('\r');

It works! Huzzah!
Thanks.

Well not quite.
It turns out that the controller that triggers the Arduino isn’t latching.
It closes the contact, triggering the Arduino to send the first message, the Arduino triggers the scaler. I see the logo.
Three seconds later it opens the contact, triggering the Arduino to send the second message, which again triggers the scaler. Logo goes away.

How do I tell the Arduino to ignore the button release and send alternating messages on button press?

I’m sure there is a tutorial somewhere. If someone could point me in the right direction I would appreciate it.
Thanks.

Never mind. I ended us using a modified edge detection sketch from the tutorials. Thanks again.