Setting up Raspberry pi is the easiest.
The first step is installing the PubNub Python SDK.
Open a terminal, and install the following:
- Python: pi@raspberrypi ~$ sudo apt-get install python-dev
- pip: pi@raspberrypi ~$ sudo apt-get install python-pip
- PubNub: pi@raspberrypi ~$ sudo pip install pubnub
go to terminal of your computer
- > sudo apt-get install git
- > git clone https://github.com/pubnub/LeapMotionServoBots.git
- > cp -ar LeapMotionServoBots/Pi leap2pi
- > 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.
- > chmod +x leap2pi/servo.py
- > chmod +x leap2pi/shutdown.py
- > 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.