Setting up a Raspberry Pi For Ruby
Tags: raspberrypi, ruby, tutorial
Published: 2019-09-04 16:43:38

---
title: Setting up a Raspberry Pi For Ruby
published: true
tags: RaspberryPi, ruby, tutorial
canonical_url: https://medium.com/@codenamev/setting-up-a-raspberry-pi-for-ruby-4824963246e8
series: Sunfounder Superkit
---

> **Updated** 9/6/19: This is _part 1_ of my [Sunfounder Superkit Series](https://blog.codenamev.com/tag/sunfounder-super-kit/).

 ![Setting up a Raspberry Pi For Ruby](https://blog.codenamev.com/content/images/2019/08/raspberry-pi-sunfounder-kit--1-.jpeg)

Ruby comes pre-installed on Raspbian, but unfortunately is not the latest version. After a bit of headache, here’s what I learned and how to make it right.

My dream is to make a split-flap display, but since I have near-zero experience working with microcontrollers I decided to pick up Sunfounder’s Superkit (v3). To be honest, it was cheap, but also comes with lots of different components to play with. Let’s see what kind of lit experiments we can build.

# Flashing the SD card

I decided to use the Raspbian OS (with desktop client), just to make the learning curve easier. After downloading [the latest image](https://www.raspberrypi.org/downloads/), I then installed [Etcher](https://etcher.io/) (as recommended) and this was incredibly easy to burn the image onto the micro SD.

# Booting Up & Configuration

Booting up the Raspberry Pi couldn’t have been easier. Jammed the micro SD card delicately in, plugged the power cable and the HDMI, and ~1minute later I was ready to go.

First thing’s first, change the system password (because security).

```
passwd
```

One nice thing about the B+ is that you can remotely control the GPIO (more on this later). Unfortunately, both this feature, and ssh, are turned off by default. So, let’s flip the table on those bad girls.

1. Launch `Raspberry Pi Configuration` from the `Preferences` menu
2. Navigate to the `Interfaces` tab
3. Select `Enabled` next to `SSH`

> **Update** : I’ve started a [small repo for all my experiments](https://github.com/codenamev/ruby-pi) that includes a [handy script to automate the remaining setup](https://github.com/codenamev/ruby-pi/blob/master/bin/setup).

For me, the latest `gpio` software was out of date and was raising hell. Let’s start this puppy up fresh:

```
sudo apt-get update && sudo apt-get upgrade
```

Boom. System configured, dependencies updated, and GPIO configured properly. Check out all the wonderful pins we get access to in the GPIO on a B+!

![Setting up a Raspberry Pi For Ruby](https://blog.codenamev.com/content/images/2019/08/raspberry-pi-b-plus-gpio-table--1-.png)<figcaption>Raspberry Pi B+ GPIO table</figcaption>

Ok, now Ruby time!

# Setting up Ruby

As of today (Jun 2018), Raspbian comes with Ruby pre-installed! In order to get some of the gems with native-extensions to build properly, I just _had_ to get `ruby-dev`

```
sudo apt-get install ruby-dev
```

# Finally Blinking a Damn LED

After _all_ that, you should be ready to use that Pi that’s just been collecting dust all these years. Just for fun, let’s perform the staple of what to do with your shiny new micro-controller: _blinking an LED_.

With a couple jumpers, an LED, and a 220Ω resistor we can safely control the state of the LED:

![Setting up a Raspberry Pi For Ruby](https://blog.codenamev.com/content/images/2019/08/raspberry-pi-blinking-led--1-.jpeg)<figcaption>Raspberry Pi B+ blinking LED with Ruby!</figcaption>

# Wrapping It Up

![Setting up a Raspberry Pi For Ruby](https://blog.codenamev.com/content/images/2019/08/wrap-it-up.gif)

Alright, I get it, not _too_ exciting. But hey, with this same setup I can see altering the code to, say, light up the LED when my tests fail.

Tune in for more of me documenting my dope ass crusade of micro-controlling justice.