Go Down

Topic: Serial comm help! (Read 518 times) previous topic - next topic

Hang

Hi all,

I got a few questions about the serial comm on the Arduino. How do you use the serial comm on the pin 0 and 1 of the digital output instead of using the USB? And instead of using the Arduino monitor to display the output, how can I use the hyperterminal instead? Is there any conversion I need to make before display to the hyperterminal?

Here is the simple program that I wanted to test out.
Code: [Select]
int potPin = 2;    // select the input pin for the potentiometer
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor

void setup() {
 pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
 Serial.begin(9600);        // use the serial port to send the values back to the computer
}

void loop() {
 val = analogRead(potPin);    // read the value from the sensor
 Serial.println(val);           // print the value to the serial port
 digitalWrite(ledPin, HIGH);  // turn the ledPin on
 delay(val);                  // stop the program for some time
 digitalWrite(ledPin, LOW);   // turn the ledPin off
 delay(val);                  // stop the program for some time
}

CosineKitty

I use HyperTerminal all the time with Arduino and it works fine.  You just need to define a "connection" in HyperTerminal with the correct baud rate, plus No Parity, 8 data bits, 1 stop bit, and no hardware flow control.  Then save that as a ".ht" file from inside HyperTerminal for future use.  You may want to tweak some of the other settings, such as auto-echoing all the characters you type so that you can see what you are typing.

Hang

Thanks for the help. I am still having trouble using HyperTerminal. I change all the options you recommended. Can both the serial monitor in the arduino program and the HyperTerminal be use at the same time? Cause right now I'm using the usb connection as my power source and it automatically output right to the serial monitor when I have it plug in. Could this be causing the HyperTerminal not to work?

CosineKitty

First of all, I built my own Arduino board based on specs I found here on the Arduino web site.  Mine is based on RS-232 serial, not USB.  I'm not sure what the implications are for USB.  But, to answer your question for RS-232, I cannot run both HyperTerminal and the IDE at the same time, because then the IDE cannot upload new versions of code to the board.  In short, once someone opens a handle to a serial port, all other programs are locked out and cannot open it.

mellis

It's the same for a USB board: in general, you can only have one program communicating with the board at a time.

To use the serial data on pins 0 and 1, you should just have to connect whatever you'd like to communicate with.  The same data will go on pins 0 and 1 as over the USB connection.  This means, though, that if both the computer and the device on pins 0 and 1 are sending to data to the board, the board will get confused.  Both computer and device should be able to read data coming from the board.  

Also pins 0 and 1 use TTL voltages (0 to 5 volts).  If you're connecting to something that expects a real RS232 serial connection, you need some kind of voltage converter to convert to its voltage (which I think is -12V to 12V and inverted).

Go Up