High, I have a very basic knowledge of code, and I am trying to transfer the press of a button press from an Arduino Uno to an Arduino Mega.
When I have only one button set up the code works perfectly, but as soon as I add a second button into the mix the code outputs randomly the first or second button.
The code may be OK.
Those radios fancy a very stable 3.3V to work properly.
They are more reliable with a capacitor soldered onto the modules power pins. 10uF is mentioned in many posts. I had luck with this 'fix'
All you are sending is the state of the buttons, one after the other after the other after the other after the other, you get the idea.
There is nothing that says which is which. You need a bigger packet - the transmissions do not catch a clue from your variable names.
Looks like now if both buttons are high, you get both listed. If both are low you get nothing. (You could put something in your emprty "else" clauses whilst testing).
If one button is down and the other up, you get continuous message about one of them, a missed packet will start telling you the other one is the one that's pressed.
Add an identifier to the packet. Check it to see which button's state is in the other part of your message. Send a little array of chars, not just one (anonymous!) byte.
If this was my project I would always send all the data in a single message and send messages at regular intervals (perhaps 5 per second) even if the data does not change. That way if the messages fail to arrive the receiving device can know that there is a communication failure.
Add an identifier to the packet. Check it to see which button's state is in the other part of your message. Send a little array of chars, not just one (anonymous!) byte.
Robin2:
Have you studied the examples in my tutorial and tried them?
...R
I have read through your examples, but am confused.
In my situation, I want a series of buttons to transmit from the RX and influence a series of IF statements on the TX. In your code I can see that it will Serial print a message, but I am unsure as to where I would place the IF statements for the two buttons and where I would place the IF statements to make the RX do the desired effect.
Sorry about the previous post, I posted before I meant to
I have been messing around with this and it has gotten me the farthest so far
Do you have any Ideas on how I could transfer the serial print so that me pressing a btn1 would light one LED and pressing btn2 would light a second LED?
Hi,
How have you got your buttons wired to the controller.
If when you press the button, the controller input gets pulled HIGH, have you got a 10k resistor between the controller input and ground to pull the input LOW when the button is open circuit?
Basically there is 5 volts to one side of the switch while the other has a wire running to the arduino and on that side of the switch there is also a 10k pull down resistor to keep the arduino reading nothing when the button is not pressed