Raspberry Pi Modules

Here's how to get Raspberry Pi and Arduino to talk to each other.

General Purpose Input Output (GPIO)

Control the GPIO pins on Rasberry PI using Python

 sudo apt-get update
 sudo apt-get install python-rpi.gpio

Font Inconsolata

Improve the user experience of your Arduino editor by installing Inconsolata

 sudo apt-get install ttf-inconsolata

Then edit the Arduino preferences:

 nano ~/.arduino/preferences.txt

and change the following lines to:

 editor.font=Inconsolata,medium,14
 editor.antialias=true

Arduino module

sudo apt-get update
sudo apt-get install arduino

Rasberry Pi & Arduino over serial

You can get Raspberry Pi and Arduino to talk to each over a serial connection

sudo apt-get install python-serial python3-serial

Open Arduino and upload this script:

 void setup(){
   Serial.begin(9600)
 }

Count upwards and send each number over the serial connection

void loop(){
  for(byte n=0;n<255;n++){
    Serial.write(n);
    delay(50);
  }
}

Open Python editor and execute

import serial

port = "/dev/ttyACM0"
serialFromArduino = serial.Serial( port, 9600 )
serialFromArduino.flushInput()
while True:
  if( serialFromArduino.inWaiting() > 0 ):
    input = serialFromArduino.read(1)
    print( ord(input) )