The Arcade Way Back Machine

This is ION’s iCade cabinet, introduced in 2011 for use with the first versions of Apple’s iPad tablet. Basically it’s a set of arcade controls (4 way joystick + 8 buttons) that connect to the iPad via bluetooth. At launch there was a companion app, “Atari’s Greatest Hits” that offered Atari’s early arcade hits: Centipede, Missile Command, Lunar Lander, etc. It all works, but with a current Raspberry Pi computer and the excellent, open source RetroPie software, you can do so much more with this hardware.

icade_original

Here’s an example of what you’ll end up with after completing this project:

IMG_1171

RetroPie is a topic by itself; you’ll want to read up a bit on the software after you get the hardware sorted. It’s a beautifully made collection of software that puts a nice (and very configurable) front-end to a collection of gaming system emulators. You can check out the full list here but I count over forty different consoles. RetroPie has modest hardware requirements, it will run on the Raspberry Pi and other platforms, including Odroid single board PCs and full size AMD/Intel based PCs, too.

OK let’s get started. Here’s the bill-of-materials for this project:

  • ION iCade (eBay listings) – prices range from $20 and up as I write this.
  • Zero-Delay USB encoder board (Amazon link) — this one costs $9.99 on Amazon.
  • Raspberry Pi 3b or 4 recommended — around $40 w/ shipping. Don’t forget a microSD card if you don’t have a spare.
  • 10″ LCD Display Panel, 1024 x 768px for 4:3 aspect ratio (Amazon)   — around $80 but this model goes on sale periodically and look out for “open box” units on Amazon. These are somewhat hard to find. More common 16:9 aspect ratio panels are much easier to source and much cheaper. I wanted this size because it fits the iCade cabinet almost perfectly and preserves the 4:3 aspect ratio of the classic games from the NES/SNES era.
  • 5V 3W DC Audio Amplifier (Amazon) — around $5.
  • 2″ 3W audio speaker (Amazon) — around $10 on Amazon. I used an old Radio Shack speaker I had on hand, but almost anything around 3W will work fine.
  • OPTIONAL: 12V DC 5A Power Supply (Amazon) — around $12. I got this only because I wanted a single power supply for the entire cabinet. A friend of mine achieved the same result by attaching a mini power strip to the cabinet, and using standard, separate power adapter for the RPi, LCD panel,, etc.
  • OPTIONAL: LM2596 Adjustable Voltage Regulator (Amazon) — around $8. As with the above power adapter, you only need this part if you want to use a single 12V DC power supply and convert the 12V to 5V to power the Raspberry Pi and audio amplifier. Otherwise, if your Raspberry Pi power supply has enough capacity (above the 2.5A or so required to power the RPi) you can share power between the RPi and the audio amplifier.

I’m not listing a few other miscellaneous items I used for my build: a small amount of wiring to connect the components, acrylic for the marquee, vinyl sticker printer paper for actually printing the marquee, and a few extra components, such as the 12V power adapter and prototyping PCB board i mounted the power jack to. I mostly had these parts already.

I designed and 3D-printed a lot of parts for this project (3D printing is especially suited for these kinds of projects): mounting brackets for the RPi, speakers, LCD display controller board (hidden behind the display), audio amplifier, and rails to hold the LCD display. I’ll post a link to the .stl files if anyone is interested; please contact me via comments.

The first step is to remove the plastic controller case from the rest of the cabinet. Note that there are a couple Torx screws used to close the case. Inside, you’ll see a small PCB with connectors and wires to twelve switches (4 on the joystick). Remove the PCB and disconnect the switches; you won’t re-use any of these parts.

The USB encoder board linked above comes with a USB cable to connect to the RPi’s USB port. Wire the joystick switches to Up, Down, Left and Right connectors, and the eight button switches to the X, Y, A, B, L1, R1 (shoulder), Select and Start connectors.

IMG_0583 Don’t worry about power for this board; it draws 5V from the RPi’s USB port. For reference, here’s the SNES controller, this will work for many different consoles and arcade games. You’ll do a one-time mapping of buttons the first time you run RetroPie.

SNES_controller_mapping

At this point, I did a bit of extra work by soldering a DC power plug to a prototype PC board and running two sets of leads off the board: one set to power the LCD panel directly (12V) and another to connect to the DC-DC converter to get 5V from 12V, to power the RPi and audio amplifier. I also ran long leads from the LED that illuminate the “coin slot” on the front of the cabinet. These are connected to 3V3 and GND GPIO pins on the RPi. There’s a built-in resistor on the LED assembly in the case.

You can remove the little stand that originally held the iPad in place; do this will open a hole through which you can run the USB encoder cable, and the three power cables. I left the encoder insider the case, closed it up at this point, and re-attached to the rest of the iCade cabinet.

VHVM6857

Don’t forget to adjust the output of the DC-DC converter (to 5.1V) before connecting to the RPi or audio amplifier.

From this point on, assembly was straight-forward. I designed and printed left, right and bottom “rails” for the LCD panel to slide into, and glued these to the interior sides of the case. Behind the panel (and not shown below) I created a bracket to hold the LCD panel controller board against the back inside panel in the iCade.

IMG_1140

On the back side of the iCade case, I wired the components together and attached everything to the back side panel using 3D-printed brackets. The end result looks like this:

61384087123__314D6FB8-DF6F-4618-8317-4BF01AB7C6A8

It’s a bit messy looking and if I did it over again, I’d try to source shorter HDMI and USB cables. I used what I had on hand. Note that the RPi4 no longer uses a full-size HDMI out connector, so you might need a “D” type HDMI to full size cable if you go with the RPi4.

The last construction step was to cut a piece of acrylic sheet to fit the space at the top of the cabinet for a marquee. Originally, I wanted this to be lit, but I couldn’t get it to look right, so I settled on designing and printing an opaque marque label. I used vinyl sticker “paper” that works well with inkjet printers. Here’s the graphic.

Arcade_banner_crop

I attached this to the front of the cabinet using small, 3D-printed L-shaped brackets. I can include these in the set of .stl files for this project, if anyone is interested. With the marquee in place, here’s what the finished cabinet looks like:

IMG_1169

The last step is to burn the RetroPie image (.img) to a micro SD card, boot up the RPi and go through the one-time control mapping process. I use Win32DiskImager for this. Copy over your game ROMs and you’re ready to go! The RetroPie web site (linked above) will walk you through the process of getting started. There are lots of customization options but burning the image to an SD card, getting configured and copying over some ROMs will have you up and running with a fully functional arcade machine.

Have fun!

 

A Home Audio Player for the Other 99%

This is Sony’s HAP-S1 High-Resolution Audio HDD Player. It’s beautiful to look at with superb audio specs, stores 500 GB of music internally, can be controlled via PC or mobile apps and can play music in a wide variety of formats: DSD, WAV, AIFF, WMA, FLAC, MP3, and AAC (and a few others).

SonyHAPS1S

But what if you don’t want to spend $1,000 for Sony’s solution, which is actually one of the more affordable on the market? Good news: there is a much cheaper alternative, that gives up almost none of the HAP-S1’s features, for less than a tenth of the price.

This is the HiFiBerry DAC+, a “shield” PC board that connects (no soldering or engineering expertise required!) to a Raspberry Pi single board computer. As the name suggests, this little board is a Digital-to-Analog Converter, that converts the digital audio processed through the

hifiberry_dac

Raspberry Pi to an analog signal that you can send out through the stereo RCA jacks to y

our home audio amplifier (or amplified speakers, etc.).

The HiFiBerry DAC+ costs about USD $29 and is available directly from HifiBerry or other online retailers. It’s compatible with most of the Raspberry Pi models — the original, 2 and 3 series, and features a 192kHz/24bit Burr-Brown digital-to-analog converter (it’s a Texas Instruments made DAC chip that has been around for a while). While I can’t compare the specs of this DAC directly to what’s inside the Sony (and similar) audio players, I’ve got it connected to my home stereo system and, to me, it sounds great.

OK, so back to the original idea of this post: pair this DAC with a $35 Raspberry Pi series 2 or 3 and for less than $100 you have all the hardware needed to stream your digital music collection to your home stereo or amplified speakers. You’ll probably want a case to house everything. I 3-D printed this case (there are dozens of different designs available for free on ThingiVerse) or you can buy a plastic case on Amazon for around $15, or even a metal case from HiFiBerry for much more. IMG_0709

So all that’s missing is software. I’m using the excellent, open-source RuneAudio software running on a Raspberry Pi3. It’s amazing how much capability the Rune project developers have given their app, not the least of which is the ease of installation and use.

Installing the RuneAudio software involves nothing more than downloading the appropriate image for your hardware (Raspberry Pi3 in my case), writing the image to a microSD card, plugging the card into the RPi, connecting RCA audio out patch cables, power and an ethernet cable (you can also configure wifi connectivity, but it’s easier to set up the RuneAudio player with a wired network connection) and booting up the RPi. You’ll find a step-by-step tutorial on the RuneAudio web site.

The software supports a wide range of digital audio formats — FLAC, WAV, MP3, AAC and others, supporting steaming from a network storage device (my music collection is stored on a Western Digital My Cloud NAS), streaming from local storage (a USB drive plugged into the Raspberry Pi), and listening to Internet radio stations.

Setup and configuration is simple and everything “just works”, similar to Apple’s products long ago. The player software can be controlled via both PC and mobile web browsers, with Android and iOS apps on the development futures list.

All-in-all, a very cost-effective alternative to dedicated home media players.

Useful sites for terrain printing

IMG_3637

I’ve come across a few websites that make it easy to generate 3D models from terrain. The best part is that you can get relatively high quality models from these sites for free.

CADMapper is fantastic for creating detailed models, down to the level of individual buildings, and is free for areas up to 1 square kilometer. The site also has whole-city models for over 200 cities worldwide. Want to print Paris? Buy a spool of filament and go for it!

For terrain models of much larger areas, I’ve tried all kinds of methods, including downloading GIS data from USGS and using software utilities to create .stl models. But none of these work as well for me as Terrain2STL. The model of San Diego county in Southern California was generated from this site.

A final site I’m aware of is Terrain Party. It’s less intuitive to use than the other sites, but is also free and can produce good results.

If anyone’s familiar with other utility sites for 3D printing, please let me know via comments.

DIY Air Quality Monitor

IMG_4111

If you’re at all concerned about the quality of air you’re breathing, you might be interested in an air quality sensor. For example, the Awair 2nd Edition is available on Amazon for $173, has great reviews, and not only detects particulates, but also chemicals, carbon dioxide, and measures humidity and temperature. It also has Alexa integration and a companion mobile app.

Awair_2nd_ed

For a lot less than this, if you’re willing to forgo some of the features, you can make your own sensor, like the one pictured above, for around $36. I’ve sourced the key components from Amazon, but that’s only because I’m lazy (and please note: these are not affiliate links; I’m not getting compensated for any of this). If you source from eBay or larger components retailers like Mouser, you might be able to bring the cost down a bit.

Here’s your shopping list:

  1. mini OLED display from Amazon for $7
  2. Arduino Uno from Amazon for $8.49
  3. Dust sensor module from Amazon for $19
  4. 9V battery connector from Amazon for $6 (pack of 5)

So what does this version do? Basically it uses Sharp’s GP2Y1010AU0F particulate sensor to measure dust and other stuff in the air, measured in micro-grams per cubic meter of air volume. You might be a bit skeptical about this (my picture shows nothing detected) but place this device on a carpet surface and stomp around it, and you’ll be surprised (or maybe grossed-out) by what the sensor measures. If you want to geek out the spec sheet for the module has all kinds of detail about how it works, including a reference guide for what constitutes “excellent” (0-35 μg/m^3) and “average” (35-75 μg/m^3) air quality.

OK, so how do you build one?  Easy:

1. Source the parts above. I didn’t mention wires for connecting the components, but these are super cheap and you don’t have to use prototyping connectors; you can also solder the connections if you want.

2. Wire everything up.  The OLED display connections are: SDA->A4, SCL->A5, GND->GND, VCC->5V.  The sensor module comes with a connector with 4 leads: yellow wire-> D7, blue wire->A0, black wire->GND, red wire->5V.

3. Load the sketch onto the Arduino Uno. I’ve saved the sketch file (.ino) and the two .stl files here.

4. 3D print the base and display holder. I tried to make this a single object file, but both pieces print better for me (Ender 3) as separate pieces. I super-glued the display bracket to the main base.

IMG_4112

That’s it! Breathe easy.

 

 

3D-Printed Art

This is a 3D-printed piece of art, a “Voronoi” lamp designed by Nik Markellov. Nik has generously made his design available for free on Thingiverse.com. I’ve extended his design by adding a set of three Arduino-controlled RGB LEDs to create a changing color pattern. Here’s what the completed lamp looks like.

IMG_2700

Creating the LED assembly isn’t difficult, but you’ll need to have some experience using a fine-tipped soldering iron. Just a few parts are needed for this: I used an Arduino Nano, three LEDs, and nine 270 ohm resistors. That’s it! I ordered common anode LEDs from Amazon, but you can use either a common anode or cathode type, the only difference is whether you connect the LEDs to +5V or ground on the Arduino. As an aside, you choose the correct value resistor depending on the “forward voltage” specification of the LEDs you’re using and the voltage of your power supply (+5V DC in the case of this project using an Arduino). Here’s a good article if you want to learn more.

IMG_2672

Start this project by soldering a common +5V rail to the corresponding pin on the Arduino Nano. In this picture, it’s the bare copper wire attached on the Nano on the left.

Next, separate the 5V pin from the three Red, Green and Blue pins on the RGB LEDs. Usually, the 5V (or ground, depending on the type of the LED) pin is identified by being a little longer than the other three leads.

Solder the 270 ohm resistors to each of the Red, Green and Blue leads, and solder wires to to the other ends of the resistors so that the three LEDs are at different heights above the Arduino Nano. This vertically “staggers” the three LEDs as you’ll see in the completed design.

IMG_2675

I connected the first LED (the highest position LED) red lead to pin 4, the green lead to pin 5 and the blue lead to pin 6 of the Arduino. Repeat this pattern for the second and third LEDs, using Arduino pins 7, 8, and 9 for the 2nd (middle height) LED and pins 10, 11 and 12 for the 3rd LED.

IMG_2676

With the LED array assembled, transfer the sketch below to your Arduino and install the assembly in the square cavity open at the base of the lamp. This code will cycle the color of each LED. You can increase the value of the delay() function call at the bottom of the loop() method if you want to slow down the color transitions.

// define pinouts
const int LED1redPin = 4;
const int LED1greenPin = 5;
const int LED1bluePin = 6;

const int LED2redPin = 7;
const int LED2greenPin = 8;
const int LED2bluePin = 9;

const int LED3redPin = 10;
const int LED3greenPin = 11;
const int LED3bluePin = 12;

void setup() 
{
      // Start off with the LED off.
     setColourRgb(0,0,0);
}

void loop() 
{
     unsigned int rgbColour[3];

     // Start off with red.
     rgbColour[0] = 255;
     rgbColour[1] = 0;
     rgbColour[2] = 0;

     // Choose the colours to increment and decrement.
     for (int decColour = 0; decColour < 3; decColour += 1) 
     {
            int incColour = decColour == 2 ? 0 : decColour + 1;

            // cross-fade the two colours.
           for(int i = 0; i < 255; i += 1) 
           {
                   rgbColour[decColour] -= 1;
                   rgbColour[incColour] += 1;

                   setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);

                  delay(100);
           }
     }
}

void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) 
{
        analogWrite(LED1redPin, red);
        analogWrite(LED1greenPin, green);
        analogWrite(LED1bluePin, blue);

        analogWrite(LED2redPin, blue);
        analogWrite(LED2greenPin, red);
        analogWrite(LED2bluePin, green);

        analogWrite(LED3redPin, green);
        analogWrite(LED3greenPin, blue);
        analogWrite(LED3bluePin, red);

}

Chemistry You Won’t Hate

I don’t remember much of my High School chemistry. I do remember being bored, not seeing much application for what I was supposed to be learning. I had a change of heart in 2010, when Apple introduced the first iPad and I stumbled across Theodore Gray’s superb Elements app.

Somehow, from reading about the elements I got the desire to start collecting them. eBay was my starting point, and lots of online sellers make obtaining samples of the more common elements almost trivial.

Then I ran across Luciteria. I warn you now: this site is dangerous, a risk to your free time and to your budget! They don’t just sell random lumps of raw materials; instead, Rasiel & co. are devoted to presenting the elements as attractively as possible. RhodiumWhere else can you find a perfect cube of rhodium for $2,800? Almost all of the more collectible elements are available for sale here, in a variety of forms, including perfect little 10mm cubes. There are elements here that you expect wouldn’t expect to find in this form, like arsenic, iridium, thallium, and uranium(!). Not all are as expensive as the platinum metals; in fact, you’ll find some bargains on this site.

With the clear plastic periodic table available on this site as a starting point, I began collecting as many of the elements in the form of 10mm cubes as I could. When I ran out of relatively affordable elements in this form, I got creative and started casting much smaller quantities into clear resin cubes. By doing this, you can significantly reduce the cost of building out your collection.

Elements Collection September 2018

Finally, you’ll reach a point where displaying the more reactive or toxic elements in clear resin isn’t feasible. There is at least one seller on eBay who can create sealed vials containing these elements in a size that fits the Luciteria display case perfectly. Contact him via his eBay store for more details.

Most importantly, have a healthy sense of respect for the elements. Avoiding accidents means having to learn about each element, and that’s most of the fun of collecting them.

A Cinema In Your Pocket (Almost)

This is the Nebula Capsule portable projector, made by Anker under their “Nebula” brand name. Confusing naming aside, this is a fantastic little gadget. It’s almost exactly the size of a soda can, projects a bright image up to 100″ diagonal and unlike many mini projectors, has very good image color quality.

I haven’t found too many competing products at the same price and feature level as this projector. Sony’s MP-CD1 is probably the most direct competitor, and no doubt features Sony’s typically excellent quality at a comparable price, but spec-for-spec (more on that later) the MP-CD1 doesn’t quite match up to the Capsule. Sure, there are plentyIMG_2426 of cheap LCD projectors on eBay, but none of them (that I can find) combine a higher-quality LCD projector with a good, built-in speaker and a full operating system (Android OS, in this case) built into the projector.

This last point is key: this little projector supports Android Apps, meaning you can stream content from Netflix, Amazon Prime Video, Sling TV, YouTube and a bunch of other media providers directly from the Capsule, over a wifi connection, without any other hardware. I find this feature incredibly useful. Besides streaming from built-in apps, you can also project directly from an HDMI source, such as a DVD/BluRay player, project videos off a USB drive, or project video directly from your iOS or Android device. I’ve tried all of these options, and they all work equally well.

Here are some key specs:

  • Supports all of these video formats: H.264 BP/MP/HP – up to 1080p MPEG-4 SP/ASP – up to 1080p DivX 4x/5x/6x –up to 1080p H.263 P0 – WVGA VP8 – 1080p (HEVC) H.265 MP 8-bit – up to 1080p.
  • Resolution: 854 x 480 pixels. More about this in a bit.
  • Battery life: 4 hours.
  • Fan noise: <30dB. It’s quiet enough for me, especially since the 5W speakers produce plenty of volume. But you can definitely hear the fan with the volume turned down.
  • Automatic keystone correction as you tilt the projector forwards and backwards.
  • IR Remote Control included. Anker makes a free “Capsule Control” app for smartphones and tablets that makes controller the projector (especially entering text) much easier.
  • Brightness: 100 ANSI lumens. In a dark room, the picture is plenty bright and the color quality is excellent. In a brightly lit room, the image will be washed out.
  • Weight :14.8 oz

OK, so about the display resolution. 480 pixels vertical resolution is only “standard” definition and gives the impression that you’ll see a grainy image. In practice, I don’t find the image quality to be an issue at all. At normal viewing distances, the image quality to me is excellent. I only find this lower resolution output to be an issue when I’m using the Capsule as a desktop display, and I’m entering or reading text (e.g. entering login credentials for a streaming app). I would never try to use this as a desktop computer display.

IMG_2419

Finally, a tip: the Capsule comes with a customized version of Google’s Play Store that isn’t very complete. If you contact Anker support (support@seenebula.com) they will send you instructions and an unlock code for a beta firmware update that includes the full Google Play store. I’ve done this and it works great.

UPDATE: Anker has just announced a Kickstarter campaign (this product was introduced via Kickstarter) for a new Capsule II product, that will offer a brighter, 720p High-Definition display. You should be able to pick up the current model at a discount and in fact Anker’s eBay store is selling  refurbished units for $280 before a 10% discount. You might be able to get an even better price by applying other eBay coupons.

UPDATE #2: Here’s a “maker” tie-in for this product: I’ve designed an easy-to-print stand for the Capsule that lets you project onto your ceiling. Great for bedtime or watching while lying down on the sofa, etc. Get it on Thingiverse here.

 

A Retro Internet Radio

This is a Philco model 46-200 AM radio, built starting in the mid-40’s around a very common five-tube design. This US company, founded in 1892 in Philadelphia, got into radio manufacturing in the late ’20’s and became a leading maker within a decade. I really like the look of this little radio, and because so many were made, it was easy to find one on eBay.

IMG_1460

The most inexpensive examples you’ll find on eBay probably won’t work. They can be restored and if you’re interested in that, here’s a book on Amazon that will walk you through the process of troubleshooting and repairing radios made around a very common design used during this period.

I decided not to try to restore the radio but instead to convert it to an Internet radio while preserving the external appearance. This project is actually fairly simple, built around a Raspberry Pi (RPi) Model 3, an external amplifier, speaker, and a few other components that I’ll cover later. Here’s what the radio’s internals looked like before I started:

IMG_1461

The first step was to remove the original circuitry. Fortunately this is easy to do, as the radio was designed to be easy to service (tubes needed to be replaced eventually). Pull the tuning and volume knobs off the shafts on the front of the radio, undo a couple screws on the bottom, and the entire assembly comes out of the radio. IMG_0011

The clear plastic shield that covers the tuning dial was cracked, an easy repair using 1/16″ inch clear acrylic available from Amazon for a few dollars. Often these radios have cases made from bakelite (handle carefully) or early types of plastic, as I believe this case is. Superglue worked fine for attaching a new shield.

My next step was to assemble the actual replacement hardware for an internet radio, built around these components:

  1. Raspberry Pi Model 3, which has onboard Wifi, eliminating the need for a separate wifi USB adapter. This isn’t critical, but it is convenient. You’ll also need a microSD (I’d get at least 16GB capacity) card to serve as the RPi’s “hard drive” and a power adapter. Powering both the RPi and the audio amplifier requires around 2.5 amps of current, so you won’t be able to power this radio from a standard USB port. I’d recommend using an external power adapter like this one.
  2. An 5V audio amplifier with integrated volume control, like this one available from Amazon for ~ $9. 5V is key as that makes powering both the Raspberry Pi and the amplifier from a single 5V power supply easy.
  3. A rotary encoder like this from Amazon for ~ $3. This device converts the turning of the tuning knob shaft to a signal we can read on the RPi as the user changing stations, which preserves the original functionality of the radio.
  4. One relatively low power speaker. I used a larger speaker than was necessary (or even desirable) because I had it lying around, but you’ll get better results by matching the speaker’s rating to the amplifier you’re using. Something like this speaker from Amazon is ideal.
  5. A momentary pushbutton switch like this. Amazon sells them in bulk but you can find smaller quantities on eBay for less. If Radio Shack still existed, that’d be a great place to get most of these components in one go!

That’s it for parts. All together, this project cost me around $100. You could probably find a vintage radio for much less at garage sales, but I really liked the design of this model.

If you’ve got the RPi, microSD card and power adapter you can start by loading the software. I followed this excellent tutorial by Giles Booth with only a few minor changes to incorporate the rotary encoder and shutdown button. Follow this tutorial to get the RPi working as an Internet radio with the following changes:

    1. Connect the rotary encoder to the RPi using as follows: CLK -> GPIO 17 (pin 11),  DT ->GPIO 18 (pin 12), +3V -> Pin 1, GND -> Pin 6.
    2. Connected the momentary pushbutton switch to RPi pins GPIO 23 (pin 16) and ground (pin 25).
    3. Modified source code for the radio.py Python app. Note the NUMSTATIONS constant. You’ll want to change this to reflect the number of stations you’ve added to the mpc playlist.
!/usr/bin/env python
# Bare bones simple internet radio
# www.suppertime.co.uk/blogmywiki
import RPi.GPIO as GPIO
import time
import os

clk = 17
dt = 18
NUMSTATIONS = 7

GPIO.setmode(GPIO.BCM)
GPIO.setup(clk, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(dt, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

# setup pin for shutdown button on GPIO 23 (pin 16)
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def Shutdown(channel):
     os.system("sudo shutdown -h now")

GPIO.add_event_detect(23, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)

counter = 0
clkState = 0
dtState = 0
clkLastState = GPIO.input(clk)

# read station number from text file
f = open('/home/pi/station.txt', 'r')
station = int(f.read())
f.close

os.system("mpc play " + str(station))

try:
     while True:
         #take a reading from the rotary encoder
         clkState = GPIO.input(clk)
         #if the last reading is different, user turned the dial
         if clkState != clkLastState:
             station += 1
                 if station > NUMSTATIONS:
                     station = 1
             print(str(station))
             os.system("mpc play " + str(station))
             f = open('/home/pi/station.txt', 'w')
             f.write('%d' % station)
             f.close
         #update previous rotary encoder setting
         clkLastState = clkState
         #slight pause to debounce the rotary encoder 
         time.sleep(0.05)
finally:
     GPIO.cleanup()

Following Giles’ tutorial and using the modified code above, your Internet radio should be functional. Here’s what mine looked like with everything wired together:

IMG_1469

It’s a bit of a mess, but that will get sorted out once the new hardware is installed in the case. Note that I used a mini audio jack and a stereo patch cable to attach the RPi audio out to the amplifier input. The rotary encoder and shutdown button connect directly to the RPi’s GPIO pins. Not shown here, but later, I attached an LED, with a 300 ohm resistor in series, powered off a GPIO pin, to illuminate the tuning dial. Using a clear LED, with enough resistance, creates a nice, vintage yellow glow.

I cut a 1/4″ thick piece of plywood to serve as a base for mounting the components. The board is sized for fit inside the case and to not move around. 3D-printed brackets are used to attach the original turning dial display, rotary encoder, audio amplifier and speaker to the base.

IMG_1488IMG_1489

With everything installed in the cabinet, here’s the final result:

IMG_1503

IMG_1508

And here’s what inspired this project in the first place!

IMG_1502

Any questions please hit me up in the comments.

Polaroid’s Blast from the Past

This is Polaroid’s new OneStep 2 instant camera, introduced in September 2017. You might be thinking that Polaroid went out of business a few years ago, and you’re right: the original Polaroid company, founded in 1937, went bankrupt in 2001. A successor “Polaroid” company was subsequently created, then also went bankrupt by 2008.

Polaroid-OneStep-2-Promo--768x768

The present-day company, started as the “Impossible Project” in 2008, bought Polaroid’s assets and intellectual property. This company was renamed “Polaroid Originals” last year. The original aim of the Impossible Project was to continue manufacturing Polaroid’s instant film, initially in a former Polaroid factory in the Netherlands.

You might remember the original version of this camera, if you were old enough in 1977. It was simple to use, with minimal controls, a fixed-focus lens, and was a best-seller for a time.

Here’s the new OneStep 2 camera next to the original:

Polaroid-OneStep-Two-Gens-enh-1024x512

It’s nice to see that Polaroid Originals kept the design of the new camera faithful to the original. Using the new camera is a great nostalgia trip and brings back lots of memories. If you haven’t taken pictures with a film camera recently, you’ll be surprised by how much light the film needs for decent exposure (hence the enormous flash unit on the Polaroid5 new camera), the lack of clarity and relatively shallow depth-of-field. Here’s a shot taken outdoors with lots of light. Indoors you’ll easily get underexposed pictures.

For fans of the format, none of this matters. The fact that this is chemical film, where the exposure develops before your eyes (although you’re supposed to keep the photo covered while it’s developing and NEVER SHAKE IT!), and that you’re left with a kind of picture that hasn’t changed in decades, is a huge attraction.

This being a maker blog, I’ve got a tie-in: a 3D-printable picture frame for these pictures. You can download the 3D model in .STL format here.

IMG_0961