hi,
i am using an arduino mega board, i am trying to communicate pc with the board using serial1(serial1.begin) port, i have connected tx of db-9 connector to rx on board,rx of connector to tx on board and gnd og connector to gnd on board, i am using windows 7 OS, i have used the following code. when i open hyperterminal and press a key, i don see anything being printed on hyperterminal. the baud rate is also correct. the compilation is completed without any error. i have the same problem even with serial(serial.begin) port communication, but this time it works fine when checked with the serial monitor of the arduino tool.
the code used,
int incomingByte = 0; // for incoming serial data
void setup() {
Serial1.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial1.available() > 0) {
// read the incoming byte:
incomingByte = Serial1.read();
// say what you got:
Serial1.print("I received: ");
Serial1.println(incomingByte, DEC);
Serial1.println("hello");
}
}