Raspberry pi setup

Setting up Raspberry pi is the easiest.

The first step is installing the PubNub Python SDK.

Open a terminal, and install the following:

  1. Python: pi@raspberrypi ~$ sudo apt-get install python-dev
  2. pip: pi@raspberrypi ~$ sudo apt-get install python-pip
  3. PubNub: pi@raspberrypi ~$ sudo pip install pubnub

go to terminal of your computer

  1. > sudo apt-get install git
  2. > git clone https://github.com/pubnub/LeapMotionServoBots.git
  3. > cp -ar LeapMotionServoBots/Pi leap2pi
  4. > rm -rf LeapMotionServoBots

You need to have these two files

  • servo.py – The code which subscribes to PubNub and drives the LEDs and servos
  • shutown.py – A shutdown button monitor to turn the Pi off.

need to find an editor that open and edit a Linux system file as the root user. Make sure the scripts are executable, then open the rc.local file for editing.

  1. > chmod +x leap2pi/servo.py
  2. > chmod +x leap2pi/shutdown.py
  3. > sudo vi /etc/rc.local

I do not know a lot about vi so I used a software that was already included in my raspberry pi. The last line of the file should be “exit 0” which allows for the clean exit of the file and the initialization of the Bash terminal. We can add any number of commands here, as long as they also run the final “exit” command.

Insert the following, just above the “exit 0” command:

python leap2pi/servo.py &&
python leap2pi/shutdown.py &&

Save the file, exit, and on boot, the Pi will automatically run those scripts. The “&&” parts make sure that every command is run. If you leave that off, the bash terminal will never load, so you will be locked out of your Pi indefinitely! so I recommend to put the last command as a comment and test the pubnub connection.