• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Communication with ATMEGA2560(Arduino)

Common

New Member
Good evening,

I hope you are well.
I am new on this forum.I am working on a project which uses an ATMEGA2650 located in a Board.

I have written a code to communicate with this board via RS232.I am using Arduino to talk to the board. But it does not seems to work at all.
I have set the right baud rate(9600).
My code seems to be ok(when I compile it), but when I upload the code into the board. The serial monitor keeps displaying "NOT printing".....So it looks like there is no "serial.available".

Can you help me please?

Here is my code:

void setup() {
// initialize serial port:
Serial.begin(9600);
}

void loop()
{
if (Serial.available()>0)
{
int inByte = Serial.read();
Serial.println("Writing");
Serial.print("AT+CGMR=0\r\n");
Serial.print(inByte, BYTE);
}
else
{
Serial.println("NOT Writing");
}
delay(1000);
if (Serial.available())
{
Serial.println("Reading");
int inByte = Serial.read();
Serial.print(inByte, BYTE);
}
}
 

Latest threads

EE World Online Articles

Loading

 
Top