Pages: [1]   Go Down
Author Topic: problem with serial communication arduino  (Read 549 times)
0 Members and 1 Guest are viewing this topic.
jordan
Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wrote code to connect arduino with pic , I don't want to explain things don't matter, but the main problem is that arduino always receives data although I don't connect any wire to pins(TX3,RX3).
this simple example , I uploaded it to arduino,  and the result is that on terminal monitor
 always print "the fire in the room : " .
and sometimes print stranger characters or nothing as shown image in down .
Code:
char ch;
int index=0;
char i[4];
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
Serial.println("power on");
}

void loop()
{
  while(Serial3.available()>0)
  {
     ch=(char)Serial3.read();
     i[index]=ch;
     index++;
     if (index==3)
 {     index=0;
       Serial.println("\n");
       Serial.println("the fire in the room : ");
       Serial.print(i[0]);Serial.print(i[1]);Serial.print(i[2]);  }
  }
}

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think that is a baud rate problem, certify the value preseted in the COM port and Arduino software.
Logged

BC, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like you are picking up noise which is then transmitted...
Logged

Pages: [1]   Go Up
Jump to: