Go Down

Topic: Using 2 Arduinos (Read 1 time) previous topic - next topic

Pauly

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.


Graynomad

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

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Terry King


...
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.
Regards, Terry King  ..On the Red Sea at KAUST.edu.sa
terry@yourduino.com  LEARN! DO! (Arduino Boards, Sensors, Parts @ http://yourduino.com

Pauly

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

Pauly

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

Quote
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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy