Go Down

Topic: JY_MCU Board problem (Connected to Arduino UNO) (Read 436 times) previous topic - next topic

yerzhik

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: [Select]

#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: [Select]

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

dxw00d

Code: [Select]
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?

yerzhik

#2
Oct 25, 2012, 04:13 pm Last Edit: Oct 25, 2012, 04:25 pm by yerzhik Reason: 1

Code: [Select]
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)

dxw00d

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

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


Replace all occurrences of mySerial with Serial.

yerzhik


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

Code: [Select]
#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)

Go Up