trouble with rs232 comunication (solved)

I followed this arduino tutorial http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232 exactly how it shows but the "hi" that should apear just apears a strange "number" (its not a number and its not a letter its something stange like ₢° and things like these) and when i type any letter on the keyboard it should send it for me back but it send another strange "number".

Anyone have any idea what it could be ?
Thanks all.

Anyone have any idea what it could be ?

Could be a coding issue. Too bad you didn't post any code.

Could be an issue with the wiring. Too bad you didn't post a schematic.

Could be that the device that the Arduino is talking to isn't doing what you think it is. Too bad you didn't tell us what it is.

Well the schematic i cant post, because as you can see on the tutorial i have posted (http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232) it does not show a schematic its just say "plug a capacitor between pin 1 and 3" and things like this, the code is that one:

#include <ctype.h>

#define bit9600Delay 84  
#define halfBit9600Delay 42
#define bit4800Delay 188 
#define halfBit4800Delay 94 

byte rx = 6;
byte tx = 7;
byte SWval;

void setup() {
  pinMode(rx,INPUT);
  pinMode(tx,OUTPUT);
  digitalWrite(tx,HIGH);
  digitalWrite(13,HIGH); //turn on debugging LED
  SWprint('h');  //debugging hello
  SWprint('i');
  SWprint(10); //carriage return
}

void SWprint(int data)
{
  byte mask;
  //startbit
  digitalWrite(tx,LOW);
  delayMicroseconds(bit9600Delay);
  for (mask = 0x01; mask>0; mask <<= 1) {
    if (data & mask){ // choose bit
     digitalWrite(tx,HIGH); // send 1
    }
    else{
     digitalWrite(tx,LOW); // send 0
    }
    delayMicroseconds(bit9600Delay);
  }
  //stop bit
  digitalWrite(tx, HIGH);
  delayMicroseconds(bit9600Delay);
}

int SWread()
{
  byte val = 0;
  while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);
    for (int offset = 0; offset < 8; offset++) {
     delayMicroseconds(bit9600Delay);
     val |= digitalRead(rx) << offset;
    }
    //wait for stop bit + extra
    delayMicroseconds(bit9600Delay); 
    delayMicroseconds(bit9600Delay);
    return val;
  }
}

void loop()
{
    SWval = SWread(); 
    SWprint(toupper(SWval));
}

But i do belive that the problem is in the "schematic" of this tutorial because i found some on the google and thats kinda diferent.

Moderator edit: Now with added Code Tagstm!

But i do belive that the problem is in the "schematic" of this tutorial because i found some on the google and thats kinda diferent.

And ?

Please post your schematic, what you've found "on the google" and how the two are "kida different".

What are you trying to talk to? Why is that such a difficult question?

the one that i found on google is that one http://www.extremeelectronics.co.in/avrtutorials/images/rs232_sche.GIF

the arduino tutorial say:
1 capacitor between 1 - 3
1 capacitor between 1 and ground
1 capacitor between 4 - 5
and 1 between 6 and ground

the on o googles tutorial say
1 capacitor between 1 - 3
1 capacitor between 2 and vcc
1 capacitor between 4 - 5
and 1 between 6 and ground
and 1 more between vcc and ground

i tried both ways with the same result =(

the arduinos tutorial also say to jump all the unused pins to vcc. the google one just say to keep it non conected.

i tried something that this tutorial said RS232 Communication - The Level Conversion - eXtreme Electronics

that says to plug out your mcu (arduino in case) and jump rx and tx to see if the comunication with the computer is working, then you open hyperterminal and the character that you send it should give you back. That has a good result so the problem is problaby in the code, does anyone already tried the code that i posted before ? ty all.

See reply #4. It is impossible to try your code without knowing what you are trying to talk to.

i´m tring to comunicate the arduino with the computer rs232 port using hiperterminal software (im doing that for a test to comunicate with a rs232 sensor later but for now forget the sensor) the both tutorial that i posted is for that arduino <--> max232 <--> pc.

I solved the problem :smiley: i dont know why but the computer recognized what i was tried to type when i used this simple code below
with this schematic tutorial RS232 Communication - The Level Conversion - eXtreme Electronics

 #include <SoftwareSerial.h>
SoftwareSerial portOne(6, 7);

void setup()
{

  Serial.begin(9600);
    portOne.begin(9600);
}



  
void loop()
{


  portOne.write('x');
  float x = portOne.read();
  delay(100);
  portOne.write('y');
  float y = portOne.read();
  delay(100);

  Serial.print(x);
  Serial.println(y);  

}

ty all

float x = portOne.read();

The SoftwareSerial::read() method that you are using here returns an int, with the useful data in the low order byte. It does not read a whole float.

void loop()
{


  portOne.write('x');
  float x = portOne.read();
  delay(100);
  portOne.write('y');
  float y = portOne.read();
  delay(100);

  Serial.print(x);
  Serial.println(y); 

}

Code tags please.

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

That code is fundamentally wrong. You should check for data available before reading it. eg.

  if (portOne.available ())
    {
    byte x = portOne.read ();
    // do something with x
 
   }