Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free.

This question already has an answer here:

I'm looking to read digital and analog pins on one arduino from another arduino. I believe that as long as they share a common ground connection this should work fine. I'm aware of I2C and I have used it for other projects, but for this I am more interested in just making the connections.

I was wondering

  1. Has anyone had experience with this?
  2. Will I damage anything if I do this?
share|improve this question

marked as duplicate by Nick Alexeev, Anindo Ghosh, RedGrittyBrick, Dave Tweed, Wouter van Ooijen Nov 5 '13 at 12:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I know you! i follow you on plus :D When in dobut, connect all the black wires :D –  Matt Clark Nov 5 '13 at 8:45

3 Answers 3

up vote 2 down vote accepted

You're definitely right about the ground.

  1. not this specifically, but it's just two chips talking to each other so it shouldn't be terribly complicated. I have managed to get a couple of micros talking to each other over I2C, SPI, and RS232 on different occasions, but never just to read IO pins.
  2. not if you're careful

One question, though: why do you want to do this? There are devices available called port expanders. The basic idea is that you talk to them over I2C or SPI and they provide access to several IO pins (usually 8 or 16) and possibly some additional interrupt-on-change functionality.

share|improve this answer

This should be relatively simple IMO.

If you want to use analog, then the code for Arduino 1 (Writer) would be as follows:

byte myByte=0;
void setup(){
pinMode(3,OUTPUT);
}

void loop(){
if(somethingHappens){
myByte++;
}
analogWrite(3,myByte); 
}

And Aruino 2 (reader) would read it as follows:

byte readByte;
void setup(){
Serial.begin(9600);
}

void loop(){
readByte=analogRead(0);
Serial.println(readByte);
}
share|improve this answer

Normally, this should work exactly like you would think, and nothing will be damaged. However, some people choose to put a resistor between the pins, just in case a programming error should accidentally set both pins to be outputs. It's not neccesary, but if you do anything where one wire is used bidirectionally and devices change input/output roles it is a good idea. Otherwise, you should be fine.

Also, Stuyvenstein's answer might give slightly odd results, because AFAIK the analogWrite() function on almost all arduino board variations is implemented with hardware PWM, not true DAC. You can use an RC filter to get real analog from the PWM though. IIRC the frequency is something like 490Hz.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.