Rf and the !(not) statement

Hi guys i would please like to know if i turn my rf transmitter off and i add this to my code will it work?

if ( ! vw_get_message(buf, &buflen))
    {
      analogWrite(PWM1,0);//motor 1
      analogWrite(PWM2,0);//motor 2
    }

The reason been I dont want my motors to keep on moving when the transmitter is off .

Thanks in advance for any help

Oh sorry another question if I have an (if) statement and i have an (else if) below it , if the (if) statement is true does it skip the else if statement till the next loop?

And with a bunch of (if) statements does it go through all of them if true?

Thanks

if I have an (if) statement and i have an (else if) below it , if the (if) statement is true does it skip the else if statement till the next loop?

Yes.

And with a bunch of (if) statements does it go through all of them if true?

Yes.

Can't understand your first post.

Undermentioned: Hi guys i would please like to know if i turn my rf transmitter off and i add this to my code will it work?

Have you tried it?

What happened?

...R

Undermentioned: And with a bunch of (if) statements does it go through all of them if true?

FWIW If u wanted to use a number of if statements and "stop" at the first one which is true (or not true for that matter) u can use a case switch with a "break" instruction. You can also add a default action if none are true / or not true as the case may be.

Sorry guys for the late reply, thanks mike for clearing that up.

Yes Robin I actually did try it the next morning but then the weirdest thing happened, my robot was working fine the previous night all I needed was to add a stop function to it , so in the morning I added the stop piece of code and then nothing worked I reverted back to my old code, Im still fault finding.

Any way What will the best function be to stop the motors I would really like if I put my transmitter off the motors will stop but now that i think of it my transmitter has delays in between transmits the the motors will jerk the whole time if the program is running .

Thanks again all

If you have written the code for the transmitter a good way would be to send a message at regular intervals and if the receiver does not detect that message it knows to stop the motors.

This is similar to the arrangement to ensure a traindriver does not fall asleep.

...R