Pages: [1]   Go Down
Author Topic: Using 2 Arduinos  (Read 954 times)
0 Members and 1 Guest are viewing this topic.
Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 130
Posts: 8620
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27418
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Red Sea, Saudi Arabia
Offline Offline
God Member
*****
Karma: 12
Posts: 579
..On The Red Sea
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Regards, Terry King  ..On the Red Sea at KAUST.edu.sa
terry@yourduino.com  LEARN! DO! (Arduino Boards, Sensors, Parts @ http://yourduino.com

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: