Help with editing code

Hi I'm not so good with programing so I downloaded an Arduino transmitter and receiver code for my 4WD rover and I edited it to make it work on my rover, the problem is that when I push the button to go forward it goes forward but it doesn't stop even when I release the forward button (I have to push the stop button to make it stop), its like this on all 4 buttons. I want to make it stop when I release the button, so that I don't need a "stop" button for it .

If you could please help me whit this code than I would be happy :slight_smile:

If you are good in programing with Arduino than there is two more things that i need help to do:
*Change the push buttons to a joystick (the one with 2 potentiometers in it).
*Add one more joystick to control a servo.

There are two files down below, one for the transmitter and one for the receiver.

_4WD_rover_receiver_code.ino (2.62 KB)

_4WD_rover_transmitter_code.ino (2.47 KB)

Hi

it think this happins because on the receiver side you never empty the buffer. there for the last massage received stays inside that buffer.

you can do 2 thinks:

  1. Empty buffer on receiver side. (i think, im not realy sure.)
  2. when none of the buttons on the tranmitter side are pressed then send Stop command.
  1. Empty buffer on receiver side. (i think, im not realy sure.)

No.

  1. when none of the buttons on the tranmitter side are pressed then send Stop command.

Yes

If thats what i have to do, than how do i put it in the code? and on the receiver or the transmitter?

Thanks for the reply

how do i put it in the code?

?
By adding extra instructions to test for the not pushed condition and stopping the motor.

and on the receiver or the transmitter?

The receiver.

The receiver.

?

i sad the transmitter?

with

  1. when none of the buttons on the tranmitter side are pressed then send Stop command.

i sad the transmitter?

You could put it there instead, it doesn't matter much so long as it is done somewhere and done correctly.

im not good with programing so i don't know how to do something like this, could somebody please make the changes to the code?
thanks.

hi

i will tell you how to do it.

look at the transmitter code.

you have

if(buttonup == HIGH){
send up code.
}
if(buttondown == HIGH){
send down code.
}
and so on...

you need to change this to:

if(buttonup == HIGH){ //Heay!!! upbutton is high
send up code.
}else if(buttondown == HIGH){//Heay!!! downbutton is high
send down code.
} else { // no button is pressed, lets send stop command
send STOP code.
}

as you see i use the else if and the else statement.

now the arduino looks IF ELSE there is a button high then send the command.
ELSE so when none of the buttons are pressed send stop code.

read this page to get a better understanding If/Else

so when none of the buttons are pressed send stop code.

Over and over and over again. So spamming the transmitter with stop commands.

Yes that the the biggest downfall. you can can say just send it one's

and it seems he uses a 433mhz system and this system likes to send the command more then ones because its realy noisy so when you send it ones it may not be received at all.

but stop the car on the receiver side would be better this way you dont send unnessery stuff. and when the transmitter runs down on power then the car just stops.