Hello ! Hi, I have a problem, I don't know how to write correctly the program that will be servo using the button through the communication nrf. My goal is a situation in which one button will increase the speed (as we hold it), and the second one will reduce speed up to zero with just one click. Now i try to write program with one button and its work like: when i put battery, motor just spin on high position, buttons doesnt work. Can someone look at this and try help me ? Thanks, I am very grateful
Tx code:
This will be a problem. The servo will not move to 150 because it is immediately commanded to go to 70. The program will not wait until it gets to 150 before moving it to 70
If there ever is data available from the radio, you'll be stuck in this infinite loop, because you never actually read the data.
if (buttonState == HIGH){
servo.write(150);
servo.write(70);
delay(15);
}
The result of this will be that the servo jerks to position 70 from wherever it is. It will never get to position 150.
There is nothing in your code that causes the servos to move anything other than flat out.
Forget about the radios for now. Connect everything to ONE Arduino. Get the servo acting the way you want on one Arduino. Then, you'll have a much better idea what one Arduino needs to tell the other.
In the end, you don't want to spam the receiver with "the button is pushed...the button is pushed...the button is pushed...".
Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.
The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work
No, its other code. In first code i just trying to send information that button is pressed then motor start spinning. Code in last post is final program that i want to send by nrf but dont know how. Even first code doesnt work properly. But i try delete and rewrite some points of first code, like someone before told me in this topic.
EDIT: Okey i got the working code for 1 button(when it's pushed, motor accelerate)
Tx