Pages: [1]   Go Down
Author Topic: JY_MCU Board problem (Connected to Arduino UNO)  (Read 378 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have Arduino UNO + Motor Shield. And I have attached the JY_MCU board (Bluetooth) to it.
I am sending data (the commands) to the Arduino through Bluetooth. The JY_MCU board accepts it and executes the command, (the motor control).
In order to receive the command I use:
Code:
#include <SoftwareSerial.h>
SofrwareSerial mySerial(0,1); // RX, TX pins
...
// in setup function
mySerial.begin(9600);
...
// in the loop function
if (mySerial.available()) {
...
}
etc

The problem is that after some time the Arduino stops responding to the commands being sent to it. However the red LED on the
Bluetooth board doesn't blink, indicating that the connection still exists.

I have decided, in order to debug the problem, to output the commands received by bluetooth using Serial.println function:
Code:
// in setup function
Serial.begin(9600);
...
// at several places in the code
Serial.println(command);
...
And after I have put that function to several places in my code, the program started to work as it should work without any mistakes or sudden stops in receiving the commands.
What is the problem? I can't understand.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
SofrwareSerial mySerial(0,1); // RX, TX pins

That line won't compile, but assuming it's correct in your real sketch, why are you trying to do software serial on the hardware serial pins?
Logged

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

Code:
SofrwareSerial mySerial(0,1); // RX, TX pins

That line won't compile, but assuming it's correct in your real sketch, why are you trying to do software serial on the hardware serial pins?

Is it the source of problem? What should I do instead?
By the way, it is compiling. (of course without the spelling mistake, correctly would be SoftwareSerial)
« Last Edit: October 25, 2012, 09:25:31 am by yerzhik » Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If your bluetooth board is connected to pins 0 and 1, then you should be using hardware serial. Remove these lines:

Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0,1); // RX, TX pins

Replace all occurrences of mySerial with Serial.
Logged

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

If your bluetooth board is connected to pins 0 and 1, then you should be using hardware serial. Remove these lines:

Code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0,1); // RX, TX pins

Replace all occurrences of mySerial with Serial.

Is it ok then to use Serial for receiving data and for debug information output? (As I am using now, Serial.println)
Logged

Pages: [1]   Go Up
Jump to: