Hi. I want to know with "vw_get_message", is there a way to use it for an if statement? Basically, if the character is "1", then this Arduino device is supposed to activate a servo, or more correctly, launch the loop that handles the servo. If the character is "0", then nothing happens.
Examples given always show it for a transmitted string, but is there a quicker way for receiving a single character?
uint8_t buf[2]; //set to minimum length, to accomadate "terminator"
...... //stuff skipped
//Servo runs, only if "1" is received
if (vw_get_message(buf,len)) {
if (buf[0] == '1')
{
for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 90 degrees
{ // in steps of 1 degree
thisservo.write(pos); // tell servo to go to position in variable 'pos'
delay(delayer); // waits for the servo to reach the position
}
for(pos = 90; pos>=1; pos-=1) // goes from 90 degrees to 0 degrees
{
thisservo.write(pos); // tell servo to go to position in variable 'pos'
delay(delayer); // waits for the servo to reach the position
}
}
Also, do I have to set length at the “transmitting” end? (this is just from the “receiving”)
How do you declare the "length" of an incoming message, especially if it's theoretically variable (since the messages I expect to use are all "2" in length, that is the actual "1" or "0" and the "terminator", can I just replace the "len" with "2"?)