There are only limited number of GPIO pins available on the Raspberry Pi, so it would be great to expand the input and output pins by linking Raspberry Pi with Arduino.
There are so many ways of connecting the Raspberry with Arduino. Recently [Oscar Liang] posted some tutorials on how to connect the two devices using different methods, including using USB cables, using GPIO pins on the Raspberry Pi and serial pins on the Arduino and using I2C communication.
Linking Raspberry Pi with Arduino Using USB Cable
This is a very straight forward method, he basically setup serial communication on both devices, so they can be listened or write to each other. The Advantage about this is simplicity, all you need is a USB cable. The down side is, it takes up a valuable USB port, that you can use somewhere else.
Detail can be found here: http://blog.oscarliang.net/connect-raspberry-pi-and-arduino-usb-cable/
Linking Raspberry Pi with Arduino Using Serial Pins and GPIO Pins
Another Method is using the serial pins on the Arduino to connect to the GPIO pins on the Raspberry Pi.
This is in some way similar to the above connection, but this time we are not using the USB port. The bad news is, you might need extra hardware to run this safely – a logic level converter because of the running voltage level difference between the two device.
There have been some arguments about whether a converter is needed on the internet. As some people suggest a voltage divider would do the job. I won’t go through the technical detail here, but I strongly recommend using a logic level converter.
Detail can be found here: http://blog.oscarliang.net/raspberry-pi-and-arduino-connected-serial-gpio/
Linking Raspberry Pi with Arduino Using i2c Communication
This way is so far the best way we have seen on the internet – using I2C. It does not need any additional hardware (a couple of cables does not count), it does not use your USB port, and it’s very easy to setup as well.
Again there are concerns about the voltage level difference between the two devices (the Pi is on 3.3V and Arduino on 5V), if there were connected together the Pi might be damaged. However, it does not seem to be the case for I2C. It turns out there are pull-up resistors that protects the Pi.
Detail can be found here: http://blog.oscarliang.net/raspberry-pi-arduino-connected-i2c/