To start off this project I would like to explain how all this will work. We will be using a form of communication called OSC (Open Sound Control) and an app called βTouchOSCβ which is available on the Google Play and Apple app store, along with pyOSC. What we will do is the following:
β Create a suitable layout for the Touch OSC app to control the Raspberry Pi (will explain further as we go)
β Upload the layout to the app
β Install pyOSC on your Raspberry Pi (I assume you already have your Pi setup and connected to your Wifi / Ethernet)
β Write a simple script in Python to handle messages from the TouchOSC app, and output the values it recieves
REASONS WHY I CREATED THIS LITTLE PROJECT:
β To show the world how easy it is control your Pi without a big hassle
β To establish an easy and legitimate tutorial (I figured this out from bits and pieces here an there, so I don't want other people to struggle with creating a simple OSC project like I had to)
I hope you enjoy this project!
BIG, BIG THANKS TO:
www.playwithmyled.com for the main image and inspiration for this tutorial!
Step 1: Gather your materials / create OSC layout
In this step we will basically have you get yourself prepared for the project by gathering all of our resources that we will require:
1. Download the TouchOSC app:
The app (last I remember) costs $5. Really, you can get it for free if you pirate it (I suggest not to pirate the app, even though it will still work).
Google Play Store Link (CLICK HERE!)
Apple App Store Link (CLICK HERE!)
2. Download the TouchOSC layout creator (to create your own GUI for your phone):
Go to this link here , scroll down to the bottom of the page and download the TouchOSC editor that suites you
3. To start building your own layout open the program you downloaded in step 2 above:
β You want to begin selecting the proper layout options for your device / phone/ tablet. iPhone screen already come with pre-configurations, but for Android devices you must select the CUSTOM layout options and put in your screen resolution. In my case I am using a Samsung Galaxy Tab 3 which is 600Γ1024.
β Next, you want to add in all sorts of widgets into your UI by βright-clickingβ on the black screen. Once you select one, look at it's setting on the left hand side and set it up to what you want to do.
SUPER, SUPER IMPORTANT INFORMATION:
When you are creating your UI, please make sure to jot down the name of your widgets and their value ranges, you will need this for future reference, also SAVE your layout file!!!
β After you create a UI that you like, turn on your smartphone / tablet and open the TouchOSC app. (Make sure you device is connected to the same Wifi network as your computer)
β On your computer: click on βSyncβ
β In the app, click on the βLayoutβ button and your computer should appear. Click on your computers name and it will ask you if you want to download the UI file you created. Hit βYesβ, or whatever comes up.
β Then, in the app, select your layout you just made and go back to the home screen
β Press βDoneβ to then view your layout that you just created to test it out and see how it works
THE IMAGES WILL GUIDE YOU THROUGH ALL THE STEPS!
Step 2: Boot up your Raspberry Pi and install pyOSC
Now that we have our UI (User Interface) setup, we next need to install pyOSC for python so that our R-Pi can easily communicate with our device using the code we write.
In this step I assume that:
β You already have an SSH connection to your Pi
β You have an established internet connection the your Pi
β And, that you know a little bit of python (I'm more of a Java guy, so python is a little different for me, so you should be fineβ¦(BTW: You actually don't need any good programming abilities to be able to do this))
β WE WILL BE USING THE FOLLOWING PROGRAMS IN THIS STEP AND THE NEXT:
β Putty β or any other SSH client
β FileZilla, so that you can copy the files over to your Pi
INSTALLING pyOSC:
1. Open up Putty and connect to your R-Pi via SSH (you will need it's IP address and connect through port 22)
β To get the IP address, simply download FRING β from the Google Play and Apple app store, it will list all the devices on your network. So from there you can get the IP of your Pi.
2. After you have established a connection, login with the Username: βpi' and password: βraspberry' (do this if you haven't already changed the Username and Password)
3. Once you are logged in, begin by typing the commands below to install pyOSC
sudo apt-get install git
Next, type in this:
cd /tmp ββββββThis will change the dierectory
git clone git://gitorious.org/pyosc/devel.git βββββββThis will download the pyOSC package
cd devel βββββ-This will change the directory
sudo ./setup.py install βββββ-This will run the install script for pyOSC
Now Were Done! π
IN THE IMAGES YOU CAN SEE THE ENTIRE PROCESS
Step 3: Making the python script (more like transferring it)
THE SCRIPT IS ATTACHED TO THIS STEP!!!!!
In this last step we will be editing a script that I wrote, to suit your needs with your UI that you created in Step 1. I have attached a simple version of the script so that it outputs the data it receives from your Android / Apple device.
For more detail:Β DIY iPhone controller for Raspberry-Pi (OSC)