Using 2 Arduinos

I have a project where I am using two Arduinos. One for a WiShield and one for other stuff like an LCD screen. I have a button I am debouncing attached to the WiShield Arduino that works fine. I need to read the button state from the second Arduino. When I do so, I get odd readings, like it switching from 0 to 1 or 1 to 0 without the button being pressed. I have the button wired as in the image.

Am I getting odd readings because I don't have +5 V coming from the second Arduino? How can I correct this or how should I have this wired up?

Thanks.

Do both Arduinos share a GND connection? If not they should.


Rob

You also need to debounce the button - otherwise when pressed, the contact to +5 (assuming normally open) will report 1010101010 several times until the connection is solid - same on release.

Personally, for each input I would use the internal pullup resistor and use the switch to ground the pin, then look for a 0 on that pin: pinMode(input_pin, INPUT); digitalWrite (input_pin, HIGH); // enable internal pullup resistor

There are no pulldown resistors in the ATMega, only pullups.

Pauly:

When I do so, I get odd readings, like it switching from 0 to 1 or 1 to 0 without the button being pressed.

This is not a debouncing issue if the button is not being pressed! It’s a noise issue. So where might the noise be coming from?

  • Ground is ‘not the same’ on 2 arduinos: Make sure it’s a good sized wire, and connected to 2 or more ground pins.

  • 'Noise" is being picked up on the wire to the second Arduino’s input pin. Perhaps use a shielded wire. Also, make SURE the pin is ‘pulled down’ by adding ANOTHER 1K resistor to ground right at the second arduino.

  • Beyond that you need an oscilloscope to see the Invisible Electricity signals…

Let us know what works.

Thanks guys. I'll give your suggestions a try when I get home.

So far adding a ground from the second Arduino seems to do the trick. I will also add another pull down 1k resistor.

Personally, for each input I would use the internal pullup resistor and use the switch to ground the pin, then look for a 0 on that pin: pinMode(input_pin, INPUT); digitalWrite (input_pin, HIGH); // enable internal pullup resistor

I do like this idea by CrossRoads as it would eliminate the 2 1k resistors. I might try that later.