user1718: How I can connect more than 10 sensors to Arduino Uno R3? I calculated it and I can connect just 4 fire flame sensors (sensors which can find a fire (a candle, for example)) and maybe 1 ultrasonic sensor. I need more for my project. I need an IR Sensor, a fire flame sensor on every side, and 1 ultrasonic sensor in front. Additionally, I need to connect 2 DC motors, 1 fan, and 1 servo-motor for ultrasonic sensor. How can I solve this? I must buy Arduino Mega?

user220: The Mega is the easiest way to get many pins is, as you said, the Mega. It has many other advantages, such as more amperage, more memory, and more UART ports. I highly recommend doing this route for a beginner, even if you get a clone instead of an official board. If none of this would be an advantage to you, there are a few different things.

Second MCU. You can get another chip identical to the Uno's to connect. This is called an ATmega standalone. They're fairly cheap. I2C is the easiest way to connect them, using only two pins from each chip. The setup will depend on the project.
Multiplexing. There is a way that you can connect more stuff than there is pins on the Arduino. This is called multiplexing. It does affect performance a little, but for some applications it is worth it. Note: this won't work well with libraries or SPI/I2C. The 4051 chip seems like a decent chip. The Arduino playground has good introduction article on this chip..


user1370: I wouldn't recommend multiplexing, but I do agree that one way is to add a second MCU.  
Another better option is to use an N-bit shift register.  These are little IC's that are exactly what the name entails: shift registers, and are much easier to setup and interface to than wasting a whole other microcontroller to add I/O's or multiplexing (which limits your application).  You effectively shift in the I/O settings that you want and then can latch those registers when you have the proper I/O sequence loaded into the register.  In other words if I wanted to have 8 new I/O pins, I could connect an 8-bit shift register to my MCU and if I wanted 4 of the first pins HIGH and the last 4 low, I would shift in 00001111b, then latch the data so that it appears on the output just as if it were any regular I/O pin on the MCU.  
They only require a few pins to operate them (, so this is an easy way to add more sensors to your system.  As always, check the datasheet to make sure the IC meets your specs (in terms of current draw, voltage, etc).
A disadvantage to this is that for an N-bit shift register, you will burn N clock cycles to load in the data.  For most applications this should be fine, but it is worth noting.  It also makes for slightly more complex code (although I am sure there are libraries for them out there). 
Note: I saw that you mentioned controlling things such as DC motors, etc.  Make sure you are not trying to directly drive them with the I/O pins, and are using a switch or transistor to control these types of peripherals.

user1737: You can easily increase number of I/O pins using an expander, e.g. PCF8574. 
The expander can be connect using your SCL/SDA pins located next to GND/AREF pins. (Here you can find detailed photo: http://forum.arduino.cc/index.php?topic=84190.0) You can connect up to 8 such expanders to extend the number of your digital pins to 64. Once you connect it, here is a code snippet of how to use it:
#include <PCF8574.h> //library available at: https://github.com/skywodd/pcf8574_arduino_library

void setup() {
  PCF8574 sensors;
  sensors.begin(0x20); //0x20 means that you connected A0, A1, A2 pins of PCF8574 to the ground
  sensors.pinMode(0, INPUT_PULLUP);
  sensors.pinMode(1, INPUT_PULLUP);
/*...*/
}
void loop() {      

  byte sensorValue = sensors.digitalRead(0); //reads digital value of 1st sensor connected to pin 0 of PCF8574 expander
  /*...*/
}

You can read more with this tutorial (note: they are using wire interface, so the code will differ. Choose the one you prefer).

1718: <p>How I can connect more than 10 sensors to Arduino Uno R3? I calculated it and I can connect just 4 fire flame sensors (sensors which can find a fire (a candle, for example)) and maybe 1 ultrasonic sensor. I need more for my project. I need an IR Sensor, a fire flame sensor on every side, and 1 ultrasonic sensor in front. Additionally, I need to connect 2 DC motors, 1 fan, and 1 servo-motor for ultrasonic sensor. How can I solve this? I must buy Arduino Mega?</p>
 220: <p>The Mega is the easiest way to get many pins is, as you said, the Mega. It has many other advantages, such as more amperage, more memory, and more UART ports. I highly recommend doing this route for a beginner, even if you get a clone instead of an official board. If none of this would be an advantage to you, there are a few different things.</p>

<ul>
<li><strong>Second MCU.</strong> You can get another chip identical to the Uno's to connect. This is called an <a href="http://playground.arduino.cc/Learning/AtmegaStandalone" rel="nofollow">ATmega standalone</a>. They're fairly cheap. I<sub>2</sub>C is the easiest way to connect them, using only two pins from each chip. The setup will depend on the project.</li>
<li><strong>Multiplexing.</strong> There is a way that you can connect more stuff than there is pins on the Arduino. This is called <em>multiplexing</em>. It does affect performance a little, but for some applications it is worth it. Note: this won't work well with libraries or SPI/I<sub>2</sub>C. The 4051 chip seems like a decent chip. <a href="http://playground.arduino.cc/Learning/4051" rel="nofollow">The Arduino playground has good introduction article on this chip.</a>.</li>
</ul>
 1370: <p>I wouldn't recommend multiplexing, but I do agree that one way is to add a second MCU.  </p>

<p>Another better option is to use <a href="https://www.sparkfun.com/products/733" rel="nofollow">an N-bit shift register</a>.  These are little IC's that are exactly what the name entails: shift registers, and are much easier to setup and interface to than wasting a whole other microcontroller to add I/O's or multiplexing (which limits your application).  You effectively shift in the I/O settings that you want and then can latch those registers when you have the proper I/O sequence loaded into the register.  In other words if I wanted to have 8 new I/O pins, I could connect an 8-bit shift register to my MCU and if I wanted 4 of the first pins HIGH and the last 4 low, I would shift in 00001111b, then latch the data so that it appears on the output just as if it were any regular I/O pin on the MCU.  </p>

<p>They only require a few pins to operate them (, so this is an easy way to add more sensors to your system.  As always, check the datasheet to make sure the IC meets your specs (in terms of current draw, voltage, etc).</p>

<p>A disadvantage to this is that for an N-bit shift register, you will burn N clock cycles to load in the data.  For most applications this should be fine, but it is worth noting.  It also makes for slightly more complex code (although I am sure there are libraries for them out there). </p>

<p>Note: I saw that you mentioned controlling things such as DC motors, etc.  Make sure you are not trying to directly drive them with the I/O pins, and are using a switch or transistor to control these types of peripherals.</p>
 1737: <p>You can easily increase number of I/O pins using an expander, e.g. PCF8574. 
The expander can be connect using your SCL/SDA pins located next to GND/AREF pins. (Here you can find detailed photo: <a href="http://forum.arduino.cc/index.php?topic=84190.0" rel="noreferrer">http://forum.arduino.cc/index.php?topic=84190.0</a>) You can connect up to 8 such expanders to extend the number of your digital pins to 64. <br>Once you connect it, here is a code snippet of how to use it:</p>

<pre class="lang-c prettyprint-override"><code>#include &lt;PCF8574.h&gt; //library available at: https://github.com/skywodd/pcf8574_arduino_library

void setup() {
  PCF8574 sensors;
  sensors.begin(0x20); //0x20 means that you connected A0, A1, A2 pins of PCF8574 to the ground
  sensors.pinMode(0, INPUT_PULLUP);
  sensors.pinMode(1, INPUT_PULLUP);
/*...*/
}
void loop() {      

  byte sensorValue = sensors.digitalRead(0); //reads digital value of 1st sensor connected to pin 0 of PCF8574 expander
  /*...*/
}
</code></pre>

<p>You can read more with <a href="http://ardugonic.blogspot.com/2010/06/icm7218a-combined-with-pcf8574-to.html" rel="noreferrer">this tutorial</a> (note: they are using wire interface, so the code will differ. Choose the one you prefer).</p>
