Hello everyone.
I need help with my code.
I made a remote with 4 push buttons using Arduino nano + NRF24. The remote is controlling 2 servo motors (continuous rotation) which are hooked to an Arduino nano + NRF24.
Please first read my code below to understand where my problem is.
My code is actually working but the remote, when I push the UP button, is not showing "serv1 = 1" in the Serial Monitor and is also not sending this information over the radio.
Any other variant is working both showing in monitor and sending over the radio. Even the servos are working, one rotating both ways and one only one way since is not receiving the information to rotate the oder way as well.
First i thought that that I made a mistake when I soldered the button but I switched the input pins (UP with DOWN) and then the UP button works but the DOWN one is not working now.
I think my problem is only in the remote.
If anyone knows where my problem is, please let me know.
Add prints in all your if to see where the code goes.
Could you have cross talks between your buttons?
If would be safer to send a struct with the two values in one transaction
You state: "My code is actually working but the remote, when I push the UP button, is not showing "serv1 = 1" in the Serial Monitor and is also not sending this information over the radio." How do you know it is software. Post a schematic, not a frizzy thing and we quickly eliminate 1/2 of the potential problem.
I'm not ignoring you guys I just don't have have enough knowledge to implement a better code. I saw a lot of examples using struct or arrays but looks complicated for me. The way the code is now is really working. 2 button's from remote control one servo and the other 2 controls the other servo. Just like the code looks like.
My actual problem was in the "if, else if" section.
The "2" will set first servo to 90° and the "5" will set second servo to 90°. You could see this in the code from my first post.
I made a Picavet which I'll tie on a kite. On the Picavet i will mount an GoPro and the 2 servos will rotate it to the direction i desire. So my project is not critical.
I opened this topic because my first Arduino should send to the second:
for serv1 the number 1, 2 or 3
and for serv2 the number 4, 5 or 6
everything was sent but de number 1 don't.
After I corrected my code as I posted above, now the number 1 is also showing up.
Yes it can be better written but right now is working and I'm fine with it.
I know very little from Arduino programming, and I'm doing now and then a project so I don't need do go soon deep in this.