So have this project it works . but when the transmitter is turned off or out of range the last values are kept which is the problem. I would like it to go to a set value if not receiving any data it's probably easy but i am new to this .
Sending binary data WILL eventually cause you serious issues, when a byte gets lost.
while (Serial.available() == 0) {}
x = Serial.read();
delay(10);
y = Serial.read();
delay(10);
z = Serial.read();
delay(10);
t = Serial.read();
// Serial.println(t);
delay(10);
a = Serial.read();
delay(10);
b = Serial.read();
delay(10);
The delay(10) is NOT a guarantee that a byte will arrive. This is a piss-poor way of reading serial data. If you need to wait (you do NOT) for 6 bytes, then wait for 6 bytes, not 1.
When you get the 6 bytes, use the 6 bytes. Do NOT unconditionally use any old crap left over in the variables.
psidat:
So have this project it works . but when the transmitter is turned off or out of range the last values are kept which is the problem. I would like it to go to a set value if not receiving any data it's probably easy but i am new to this .
If the Tx sends a message at a regular interval the Rx can note the time when a message arrives and if the gap to the next message is too long it can take action.