keep motor running while button pressed over 433mhz receiver transmitter sender

Hello everyone,

I´ve been reading a lot her, since I startet Arduino but just became a writer here recently.
I just bought a 433mhz sender/receiver bundle which works quite well.
In fact I´ve chosen this method to remote-control motors which are attached to another arduino.

My problem is - couldn’t find a solution yet, although searching for hours - that I want the motors to move as long as I press a button.

Here´s a part of my code from the sender:

void setup()
    Serial.begin(9600);	  // Debugging only
    vw_setup(1000);	 // Bits per sec
    vw_set_tx_pin(14); //Transmitter Data Pin to Digital Pin 3
    for(int i = 0; i<6 ; i++)
      pinMode(remotePins[i], INPUT);

void loop()
  char *msg2;
  while(digitalRead(forward) == LOW)//simple button with no external resistor 
    char *msg2 = "1";//send 1 to the receiver
    digitalWrite(13, true); // Flash a light to show transmitting
    vw_send((uint8_t *)msg2, strlen(msg2));//send the byte to the receiver
    vw_wait_tx(); // Wait until the whole message is gone


void setup()
    pinMode(PoM1a, OUTPUT);
    pinMode(PoM1b, OUTPUT);
    pinMode(PoM2a, OUTPUT);
    pinMode(PoM2b, OUTPUT);

void loop(void) {
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen)) // Non-blocking
      int i;
      for (i = 0; i < buflen; i++)
void forward_a()
  digitalWrite(PoM1b, LOW);
  analogWrite(PoM1a, 200);  
  analogWrite(PoM2b, 200);
  digitalWrite(PoM2a, LOW);

Unfortunately the motor stop repeatedly in short intervals. I´d like to solve this in order to make the motors turn as long as I press the button and stop as soon as I release.

I´ve only found solutions for bluetooth, which I don’t want to use yet.

Can anyone give me a hint (or a solution :-)).



What about sending a message (perhaps just B for Begin) when the button is pressed and sending another message (E for End?) when the button is released.


Thanks for your help R.

Never dealt with button-release-events. Guess I´ll look for that.


Never dealt with button-release-events. Guess I´ll look for that.

Nothing so complex.

Just check if the button is pressed after it was previously not-pressed and a little later check if it is not-pressed after being pressed.

If we assume digitalRead() gives LOW when the button is pressed ...

curPress = digitalRead(buttonPin);
if (curPress == LOW && prevPress == HIGH) {
    // button has just been pressed
if (curPress == HIGH && prevPress == LOW) {
  // button has just been released
prevPress = curPress;


Hello R,

thanks again for your support. Helped quite a lot!

Additionally, as I still had some outtakes occasionally, I checked the wiring again, just to see that I - don't ask me why - forgot to add some decoupling capacitors to the receiver in order to reduce noise from the power line.
All in all it works much better now.

I´ll add some more code (want to add a display) and look whether everything keeps working smoothly.
Guess I will open a new thread, if I´m facing new problems.

You made me solve this one. Thanks!



im doing something similar,

Dont forget to add some sort of ping into the comms to make sure you still have signal,
otherwise your car or whatever it is may drive away and never get a signal to stop

Thanks for the hint about the pings. I'll keep that in mind. Have to look for information on this issue when the basics are done.

The problem im now running into is making the ping not adversly affect the rest of the data being sent,

when the time comes look into using stopbits on the transmition, or something similar to let you change a flag that controls output or input functionality.

Or buy real 2 way simultaneous radios,
send me a pm when you have the basics done if you like and i’ll help out if i have learnt anything useful by then