Reversed Question Make

Hi,

I am also having a problem with it but it changes to other symbols as the value goes up. I am using a joysticks x and y values as the values. they only come up when it has the write command other wise they aren't there. the baud rate is set to 38400. Is there anything that I can do to solve the issue?

int xAxis, yAxis;
void setup() {
  Serial.begin(38400); // Default communication rate of the Bluetooth module
}
void loop() {
  xAxis = analogRead(A0); // Read Joysticks X-axis
  yAxis = analogRead(A1); // Read Joysticks Y-axis
  
  // Send the values via the serial port to the slave HC-05 Bluetooth device
  Serial.write(xAxis/4); // Dividing by 4 for converting from 0 - 1023 to 0 - 256, (1 byte) range
  Serial.write(yAxis/4);
  Serial.print(xAxis);
  Serial.print("__");
  Serial.print(yAxis);
  Serial.print("--");
  
  delay(20);
}

Why are you writing AND printing the values?

Have a look at the examples in Serial Input Basics - simple reliable 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)

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

It makes debugging much easier if you send data in human readable form. I would only send binary data if it was the only way to achieve the required performance.

…R

Thank for the advice it really is helping to see where the question marks are. The question marks are in between the values like this <value1,value2>⸮~<value1,value2>. they also only appear when a value is above zero when they are at zero they disappear. Is there anything that I can do to try and solve this issue? Could it depend on the Bluetooth chips I am using?

Please see reply#1

I did that so I could see that values in the serial monitor, while the values are being written. Should I not do that?

write writes the binary value which might be a non-printable character. print converts to text and sends ascii text to the serial monitor

Could that be the reason why the question marks and other symbols show up?

There’s a very quick and easy way of finding out.

Could you tell me this knowledge to find out what the problem is?

You've got the software and the hardware - we don't

Just try it.

What do I have to do to find out if it is the problem?

Change the code.

See reply #6.

You have to wait five minutes between posts here - you could have tried changing the code and testing many times over in the time you’ve been waiting to post.

I have no clue what anyone is talking about on this post. I assume that everyone knows what they are talking about in the post that they made here. But I am just very new to arduino so this seems like a foreign language to me. Is there any way that someone can help explain it to me in similar terms?

void setup() {
  Serial.begin(38400); // Default communication rate of the Bluetooth module
}
void loop() {
  int xAxis = analogRead(A0); // Read Joysticks X-axis
  int yAxis = analogRead(A1); // Read Joysticks Y-axis
 
  // Send the values via the serial port to the slave HC-05 Bluetooth device
  Serial.print(xAxis);
  Serial.print("__");
  Serial.print(yAxis);
  Serial.print("--");
 
  delay(20);
}

What happens now?

The symbols are gone and the values read perfect. But the values that that don't send to the second arduino that I am trying to use.

How do you know this?

Do you understand what I did to your sketch?

Now there is a second Arduino; would be good to have known that from the beginning. Including the source code of the second one.

Which Arduinos are you using in this project? How are they wired?