pl find attached here with the two programs (master & slave) done on two arduino boards with two HC05 blue tooth module as master and slave.
with these programs when i change the joystick no moment
t in motor and also no display of joystick data on receiver serial monitor.
If I send some integer value from Master serial monitor and press send the same value is displaying on slave serial monitor. And motor is moving one step. If next time sends the value no moment in motor.
Mastercode:
#include <SoftwareSerial.h>
SoftwareSerial BTSerial(10, 11);
int potValue =0;
void setup()
{
Serial.begin(38400);
Serial.println("Arduino is ready");
BTSerial.begin(38400);
}
void loop() {
potValue=analogRead(A0);
int potValueMapped=map(potValue,0,1023,0,255);
Serial.write(potValueMapped);
if(Serial.available())
BTSerial.write(Serial.read());
if(BTSerial.available())
Serial.write(BTSerial.read());
}
read the two bytes of int separately - the first part is sent back to the master and the second part is used for the servo.
Another problem is that master is sending the data too often - it is sending it as fast as loop() can repeat. Sending data about 5 times per second should be sufficient to get a good response.
Rather than trying to fix all that, it is much easier to debug a program if you send data as text using Serial.print()
Have a look at the examples in Serial Input Basics - simple reliable non-blocking ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.
The technique in the 3rd example will be the most reliable. It is what I use for Arduino to Arduino and Arduino to PC communication.
You can send data in a compatible format with code like this (or the equivalent in any other programming language)
odces:
I have not clearly understand the examples please.
I 'm sure you did understand the titel. And the first words in the first sentence. Pretty sure even more. But of course there is a point you don't understand. So please ask a concrete question right there where the first question arises.
Concrete questions will help a lot to get you going
best regards Stefan