I have an arduino mega and about 7 limit switches hooked up to the pins. The inputs are configured as INPUT_PULLUP. However, the corresponding input pins was able to read other limit switches. ( pressing any of the limit switch activates the code, although its set to only read from one pin ). also, the other pins couldnt read inputs when any of the switches is pressed. Does anyone knows what might be wrong here?
the actual code is kinda long and yeah i did use some delay. The schematic is basically, its just 5v connected to NO, then ground to arduino pins. The code is basicially do something when the switch is pressed. Thanks for you reply !
its like this but 7 switches. also i should be noted i didnt use a resistor because i kinda dont have 7 1k resistors so i just used to pullup function. however, it still disconnects my arduino when the switches close.
If you have enablet INPUT_PULLUP, the arduino putts Vcc over a 10K internal resistor to that INPUT.
All you have to do is to connect you switch to that INPUT and GND - that should work.
Just note that this switch is INVERTET - it gives HIGH if no KEYPRESS or LOW if you press the button!
So action has to take place when the Input goes LOW.
Thank you friends. I have tried the recommended method (NO to arduino pins and COM to GND )and the switch is responding perfectly. However, i will still have to test out the initial problem where the switches are interfering with each other and when a switch is activated, that other switches can be read b y the arduino independently. Will report back! thanks again
UPDATE!! both of the initial problem is solved. Activating the second pins does not trigger the first pin anymore, also when the first switch is activated, the second can operate normally! I also tried to space out the pins so they are not all cramped in one area . Thank you guys again
Also, if anyone got any clue what went wrong with my initial set up, can you please share. Seems like i have a misconception on the fundamentals. If not, its working now anyways CHEERS !