Run out of pins!! Can I regain use of pin 0 and 1


I've got a Duenava (2009). I run out of pins because I need to use BOTH a Adafruit Waveshield and a xport.

Is there a way to regain use of pins 0 and 1?

Why not increase your number of I/O's through the use of Shift Registers or an ADC/DAC chip?

You can also use any of the analog input pins as digital I/O pins if you are not using all of them.


Thanks for the suggestions but I do not know how to do neither of these.

Is there a tutorial on Shift Registers or using analog input pins as digital pins?

Also, I think another solution is to use another Arduino with the advantage of spreading out the processing power..

When connecting 2 arduinos using analog pins (1 arduino set as input, another output), do I connect them directly or should I use a resistor. Do I connect the power and ground of both arduino together?

Changing the analog input pins to digital pins is easy, look for the NOTE section towards the end of this:

You can't wire a analog input pin from one Arduino to an analog output pin from another directly because the analog output is not a true analog voltage but rather a PWM digital signal. It would first have to be wired through a low pass filter to derive a analog value.

When wiring two or more Arduino boards together one must always connect a common ground wire between them. They may share power or use independent power depending on the current requirments. Lefty

'low pass filter'

equals to a capacitor connect between the pin and GND? What value of capacitor works?

A simple low pass is a series resistor followed by a cap to ground, a RC low pass filter. The values needed depend on the period of the PWM. I think there are some suggested values somewhere in the Arduino site. Anyone know good values for the standard PWM analog write outputs?



How about digital data?

How does one connect 2 arduino and have them talk digitally?


Just connect them together and make one an input and the other an output. Then one can read the logic value on the other. To communicate actual bytes between the two you would have to use the software serial library found in the playground.

I would think that you would be better off sending messages between boards rather than connecting digital or analog pins. For example, you could have one arduino send the values of analog or digital inputs over the serial port to a second arduino. But note that you can get one mega for about the same cost as two standard Arduino boards.

BTW, how many more digital and analog inputs do you need.

I was thinking of serial communication but how do I syncronised the reading and sending.... how do I make sure that the data is there when one arduino reads it and vice versa...

I found some RC low pass info but no mention of what the values of RC are for my purpose...

If I use R = 4.7K C = 1 mF

woulkd it be OK?


How best to send the data depends on the data. What do you need to send?

If one board is waiting for a signal from the other board before it does something then you can just have a loop on one board, constantly receiving data and an 'if' so that it doesn't acknowledge the input unless it is above 0. You can then just use 'else' so when it receives a command it does whatever it's meant to do.

If you can elaborate a bit more then people will be able to provide more detailed help. What exactly are you trying to do? What data do you want to send to the second board? What do you then want the second board to do?


Here's what I need to achieve

Arduino 1 aka A1 : Waveshield

Arduino 2 aka A2 : Ethershield

Because both uses SPI, I can't have 1 Arduino with both shields.

A2 will have sensors and the data will be send to internet site A2 will also need the data from sensors so that when I press a button, it will speak the values of the sensors.

3 sensors: Analog sensing light brightness Analog sensing something like a potentiometer Digital pin with the Dallas Temperature sensor

I need the get the data across from A2 to A1.

have you checked with ladyada to see if the waveshield can be used with the ethernet card? SPI is a bus so in theory multiple devices can be used.

If not, here is some code to pass information from one Arduino to anther. BTW, although the Dallas chip only uses one pin, the temperature information is an integer so you need to pass three integers across.

the sending side can do this in loop after you have obtained the three values:

  Serial.print('H'); // unique header to identify start of message
  Serial.print(",");  // note that a comma is sent after the last field
  Serial.println();  // send a cr/lf
 * SerialReceiveMultipleFields.pde
 * This code expects a message in the format: H12,345,678,crlf

const int NUMBER_OF_FIELDS = 3; // how many comma seperated fields we expect
const char HEADER = 'H';        // a single character header to indicate the start of a message   
int fieldIndex = -1;            // the current field being received, -1 means waiting for header
int values[NUMBER_OF_FIELDS];   // array holding values for all the fields

void setup() 
  Serial.begin(9600); // Initialize serial port to send and receive at 9600 baud

void loop()
  if( Serial.available())
    char ch =;
    if(fieldIndex == -1) // waiting for header
      if( ch == HEADER)  // is this the Header?
        fieldIndex = 0; // yes, get ready to receive the first field        
    else   // if not waiting for header then must be field data
      // so receive digits for the fields    
      if(ch >= '0' && ch <= '9') // is this an ascii digit between 0 and 9?
        values[fieldIndex] = (values[fieldIndex] * 10) + (ch - '0');      // yes, accumulate the value
      else if (ch == ',')  // comma is our seperator, so move on to the next field
        if(fieldIndex <  NUMBER_OF_FIELDS)   
          fieldIndex++;   // increment field index                
      if( fieldIndex == NUMBER_OF_FIELDS )
        // All fields received
        for(int i=0; i < NUMBER_OF_FIELDS; i++)
          Serial.println(values[i]);    // replace this with code that does something with the values           
          values[i] = 0; // clear the values to zero ready for the next message
          fieldIndex = -1;  // wait for another header

have fun!