I'm sorry if this is in the wrong category, this is my first post. I've been having trouble sending messages over a radio module. So what was supposed to happen is that the radio module would send a message corresponding to the button I press, which would turn on a corresponding LED, red or blue. I got it to work only that it's kind of sporadic when it works. It always sends the signal but doesn't always turn on the right LED. For example, I'll press the button for the red LED and it would turn on the yellow LED, vice versa. I attached the codes for the receiver and the emitter. They can be identified by the comment on the top stating the pin number for each data pin.
Radio_module_2_message_send.ino (921 Bytes)
Radio_modeule_2_message_recieve.ino (930 Bytes)
pinMode(Buttonred, INPUT);
pinMode(Buttonyellow, INPUT);
digitalWrite(Buttonred, LOW);
digitalWrite(Buttonyellow, LOW);
Do the button switches have pull down resistors on those inputs. Why write a LOW to an input?
The more usual way to wire switches is to connect one side of the switch to ground and the other side of the switch to an input set to pinMode INPUT_PULLUP. The input will read HIGH when the switch is unpressed and LOW when pressed. Adjust program logic accordingly.
More members will see your code if you post it according to the forum guidelines.
Thank you for that, although it didn't help. While that does help me set up buttons easier in the future, it still is quite random. I checked the serial monitor of the receiver and its turning on the right LED according to the message, but the message being sent is wrong. Could the similar length of the strings be a problem? Also, the buttons when not being pressed still said the buttons were in a LOW state until being pressed. So other than the wiring the buttons seem to function in the exact same way. I'm still glad that you showed me that because it makes it easier to set up. I'll attach the updated code below.
Radio_module_2_message_send.ino (857 Bytes)
Radio_modeule_2_message_recieve.ino (952 Bytes)
I am on my tablet right now. I cannot easily open ino files on my tablet. That is one reason that I posted a link to the forum guidelines so you would know how to post code to the forum so we do not have to download it. I will look at your code later when I get to my PC.