HI, I am stumped and have so many variants of the button being pressed code I am at a loss. I have an home security system on mega 2560 with keypad code (mostly from an existing project on Internet and changed to my requirements). Alarm turns on and off with keypad as it should, but now I want to add a remote with receiver to also turn off or on alarm. (Basically a relay being closed on receiver)
button defined
int remotePin = 22;
void setup(){
pinMode(remotePin, INPUT); //Remote control
This is where I have the issue, I have tried the disabled remotestate and if digitalread but if I close the relay on pin 22 the alarm does not activate
You have a button on pin 22 and looking for a HIGH. Do you also have a 10k pulldown resistor connected from pin 22 to ground so it doesn't "float" HIGH randomly?
Start with reading the forum guidelines. Then go back and edit your post to include code tags. Preferably auto format your code first. Then make a new post with the full code and the additional information required. The guidelines give you all the information you need to make a post that is likely to lead to a useful response.
You have a button on pin 22 and looking for a HIGH. Do you also have a 10k pulldown resistor connected from pin 22 to ground so it doesn't "float" HIGH randomly?
I have tried the internal pull down statement with no effect. I will try with an external resistor for good measure.
The standard way to use a button / switch is to connect it between the input and ground. Then use either internal or external Pull Up. The digitialRead() function will return LOW when the switch is closed.
You say you have a problem in "the void loop section" but you haven't posted the code for that "section". It makes it difficult to help.
Posting little fragments of code often doesn't work because error the often isn't where you think it might be. If it was you would probably already have found it yourself.