Raspberry Pi | openFrameworks Intro

— Jakob Marsico @ 4:39 pm

Intro

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:

  1. Rasbperry Pi Model B or B+
  2. 8GB SD card (either micro or standard size, depending on your rPi model)
  3. Ethernet cable and (if needed) an adaptor to connect the ethernet to your laptop
  4. HDMI -> DVI cable
  5. 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.

  1. Download the operating system image we’ll be using in this course from here: DROPBOX LINK
  2. Install the OS image onto your rPi’s SD card by following these tutorials:
    1. OSX: tutorial one  OR tutorial two
    2. Windows: tutorial
    3. Linux: you’ve probably done this before, if not: tutorial
  3. This image is large (8GB!!), so both steps will take a long time.
  4. Eject the SD card once the process is finished.
  5. Test your image:
    1. Insert your SD card in the rPi.
    2. Connect the rPi to a monitor.
    3. Plug in the power adapter.
  6. 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.

Get Connected

  1. If you’re on CMU’s campus, you need to connect to the CMU wifi network on your laptop (not CMU-SECURE).
    1. open a browser and navigate to rawr.net.cmu.edu
    2. follow the directions to login and register your machine.
    3. check your connection and make sure you’re connected to CMU network, not CMU-SECURE
  2. Turn on internet sharing on your laptop. Make sure you are sharing your WiFi connection with devices connected via ethernet.
  3. Plug things into your rPi. It’s best to plug the power in LAST.
    1. ethernet -> computer
    2. HDMI -> monitor
    3. keyboard
    4. GPIO connector (if you have one)
    5. Power!
  4. You should now see the boot sequence on your monitor. Wait until this is finished.
  5. You’ll see a login prompt. Login.
  6. After you’re logged in, type ifconfig
  7. 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.
  8. On your laptop, open a terminal window (iTerm, Terminal, etc.).
  9. Type ssh pi@<enter.ip.address.here>
  10. Enter the rPi’s password.
  11. Put on your shades. You’re in.

Samba Share

  1. This part of the tutorial is for OSX. For Windows, hop over to this tutorial.
  2. Open Finder
  3. Type Command+K
  4. enter: pi@<enter.rPi.IP.address.here>;
  5. enter your password.

Do Things

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:

  1. Open the oF files in a text editor on your laptop
  2. Change the OUTPUT pin number (be mindful of WiringPi pinout!!!)
  3. Save the files.
  4. Connect an LED (be mindful of WiringPi pinout!!!)
  5. In SSH, re-compile and re-run the app.

 

 

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2017 Making Things Interactive | powered by WordPress with Barecity