With a few short steps, you’ll get an openFrameworks sketch running on your Raspberry Pi and controlling the GPIO pins. For this tutorial, you will need:
- Rasbperry Pi Model B or B+
- 8GB SD card (either micro or standard size, depending on your rPi model)
- Ethernet cable and (if needed) an adaptor to connect the ethernet to your laptop
- HDMI -> DVI cable
- 5v 1.5A power supply with microUSB connector
SD Card Prep
Before you can begin developing on the Raspberry Pi, you’ll need to prep your laptop and SD card.
- Download the operating system image we’ll be using in this course from here: DROPBOX LINK
- Install the OS image onto your rPi’s SD card by following these tutorials:
- This image is large (8GB!!), so both steps will take a long time.
- Eject the SD card once the process is finished.
- Test your image:
- Insert your SD card in the rPi.
- Connect the rPi to a monitor.
- Plug in the power adapter.
- If the rPi boot sequence ends with a login prompt, the image was burned correctly. If not, give it another shot and pay very close attention to the directions.
- If you’re on CMU’s campus, you need to connect to the CMU wifi network on your laptop (not CMU-SECURE).
- open a browser and navigate to rawr.net.cmu.edu
- follow the directions to login and register your machine.
- check your connection and make sure you’re connected to CMU network, not CMU-SECURE
- Turn on internet sharing on your laptop. Make sure you are sharing your WiFi connection with devices connected via ethernet.
- Plug things into your rPi. It’s best to plug the power in LAST.
- ethernet -> computer
- HDMI -> monitor
- GPIO connector (if you have one)
- You should now see the boot sequence on your monitor. Wait until this is finished.
- You’ll see a login prompt. Login.
- After you’re logged in, type
- This will list your network connections. Look for the connection labeled
eth0, then look for the
inet address. That is your Raspberry Pi’s current IP address, write it down.
- On your laptop, open a terminal window (iTerm, Terminal, etc.).
- Enter the rPi’s password.
- Put on your shades. You’re in.
- This part of the tutorial is for OSX. For Windows, hop over to this tutorial.
- Open Finder
- Type Command+K
- enter your password.
Now that you can control your raspberry pi through SSH and access and edit its files through Samba, you’re in a position to do just about anything possible with the rPi. Most importantly, you can do it from the comfort of your laptop. No need to hook up a keyboard to your Pi; if you’re not doing graphics work, you don’t even need a monitor.
Let’s try a sample openFrameworks sketch to learn how to operate within the rPi+oF development workflow.
1. In your SSH session, move to the openFrameworks folder:
2. List the files and folders in that directory:
3. Move into the apps/myApps folder and look around:
4. Go into the wiringPi_example folder
5. With openFrameworks, you want to run the compile command from the base directory of your application (which always needs to be in this myApps folder). To compile:
If you don’t get any errors, run the app:
In class exercise:
- Open the oF files in a text editor on your laptop
- Change the OUTPUT pin number (be mindful of WiringPi pinout!!!)
- Save the files.
- Connect an LED (be mindful of WiringPi pinout!!!)
- In SSH, re-compile and re-run the app.