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.
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.
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.
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.
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.