I Like Big Buttons

The Premise

In early 2018, my friend Steve had an idea.  His church supports missionaries, and for fundraisers, they sell lunches to the congregation.  In the past, they had volunteers prepare and serve the food.  It was a lot of effort, and Steve thought that it could be improved.  He thought that having a restaurant make the food would allow them to charge a bit more for the food, and might draw more attention.  He was right of course, and now he wanted a way to engage the participants even more.  He wanted some kind of visual progress indicator.  something that would get people excited about participating in supporting the cause.

“What if we had a big button that people could push when they buy a lunch, and then have a big display of how many lunches we’ve sold?”

That sounded like a cool idea to me.  So, I set out to build just that.

The Architecture

button box setup
If this is a smart TV with a browser, the laptop can be eliminated

I tried to make this as simple as possible. No, really I did!  However, the constraints of the environment dictated otherwise.  I thought the simplest thing would be to have a button attached to a Raspberry Pi, which would be attached to a screen via an HDMI cable.  However, the display needed to be relatively far away from where people would be paying for lunch, and running a long HDMI cable was not acceptable.  Steve mentioned that they had an extra laptop that they could connect to the TV, so this seemed like a reasonable solution.

After some noodling, I decided that I’d have a big button box with a Raspberry Pi inside. The Pi would host a web server that publishes a page with the count on it.  The laptop connected to the TV would access the web page and display it on the TV.

Is this the simplest design?  Not by a long shot.  Would it be fun to build?  Absolutely!  I also like the idea that this solution is self-contained.  If the TV has a browser, then the laptop can be removed from the setup.

The Button Box Design

large button
That is one big button!
lit button
Ooh! Shiny!

The hardest and most interesting part of this project to me was the button box.  I’d been itching for a project to use the laser cutter at our makerspace, theLab.ms.  While I could have just used a tool to generate the dimensions of the box with appropriate notches for assembly, I decided it would be fun to figure it out on my own.  Here’s what I wound up with…

2D OpenSCAD layout
the 2D primitives in OpenSCAD were perfect for this project!

I made the first prototype with cardboard, which worked out perfectly!

Cardboard prototype
looks good so far!
cardboard prototype assembled
Everything fits with a reasonable amount of space for wiring

Happy with the results, I moved on to the 2nd prototype, which was made out of MDF scraps at the makerspace (I think I also got some hardboard in there, too).

MDF prototype bottom
All the holes lined up! The square plate on the lower left is the shutdown button.
detail on shutdown button
I mounted a momentary contact button upside down to serve as the shutdown button

Since this button box would be operated by non-technical folks, I decided I should add a shutdown feature to prevent damage to the SD card.  When the button is held for 2 seconds, a shutdown command is sent to the Pi.  Of course, nothing stops the user from just disconnecting power, but at least the capability is there.  Since the Pi doesn’t have any built-in capability to shutdown the OS, I added a momentary contact button to the bottom of the box to serve this purpose.

Everything was going great until I received my acrylic sheets.  I thought I was getting 3mm acrylic sheets, but I actually ordered 2mm acrylic sheets.  *sigh*.  But thankfully, I made the material thickness a variable in my OpenSCAD model, so I just needed to change that variable from a 3 to a 2, and adjust the placement of the power connector hole (that took a bunch of trial and error).

off my 1mm
PSA: 3mm does not equal 2mm

After the adjustments, I re-cut the box from the spare sheet of acrylic (always a good idea to get more than you absolutely need in case you make a mistake!).

final internal wiring
I really like the Perma-Proto hats from Adafruit!

To keep the wiring nice and clean, I used a Perma-Proto hat from Adafruit. I’ve used them in a few projects now and I’m hooked.  For the relatively small circuits I’m making, they’re perfect, and don’t add much to the footprint of the project.

finished box unlit
I like the way it turned out! Unfortunately, you can see along the top front edge where the acrylic cement leaked and marred the surface. A little acrylic cement goes a long way.
finished button box powered on and lit up
Who can resist a giant shiny button?

The RESTful Web App

I really enjoy projects that involve physical builds as well as software.  In the spirit of over-engineering things, I decided to make my counter a RESTful Web Service.  You can find the source code on bitbucket.  When the big button is pressed, python code sends an HTTP request to the web server, incrementing the stored count.  The web page showing the count updates every 1/2 second.  For the shutdown, holding the button on the bottom of the box sends another request that executes a graceful shutdown of the web server and the Raspberry Pi.

A Demonstration

Here is the whole thing in action!

Next Steps

  • Test it out in the target environment
  • I’d like to make the typeface fixed-width
  • There is code to set a target number.  I’d like to add some animation that is triggered when the goal is reached

The Rickrolling Toilet

The Idea

In 2015, my church decided to revive their Fun Fair event.  They encouraged folks to take a look at some of the old games and refurbish them if they were interested.  I found an old game called “Dunk It”.  It consisted of a toilet seat bolted to a green wooden frame.  The goal was to toss a roll of toilet paper through the hole of the toilet seat to win a prize.

My inner 5yo. thought this would be my game.  But, I couldn’t just leave it as is.  I needed to make some… improvements.  The premise of the game was simple, but it lacked something.  There was no feedback for the player.  So, I set out to give it a voice.

My first inclination was to use an Arduino with an audio shield.  However, I was trying to minimize the cost, so I thought I’d use something I  already had on hand, a Rapsberry Pi A+.  This would handle the audio, and the programming would be relatively simple.

Alpha/Beta Version

To prove the concept, I thought I would wire up a light sensor (Light-dependent Resistor) to the Raspberry Pi.  This was not as straightforward as I’d hoped, since LDRs are analog devices and the RPi only has digital I/O pins.  So, after a bit of searching, I found a technique to read analog values from a digital I/O pin using a simple circuit.

Once I got this wired up, I stole some code to make the LDR reading work.  I combined that with some code to play back audio and the alpha version was working…

Version 1.0

I foolishly ignored the advice to always put a resistor in series with an LED.  And it bit me in the behind.  An hour before the fun fair, the LED blew out, and I wasn’t able to leave and get a replacement.  Lesson learned.

Version 2.0

For Version 2.0, I wanted to make some significant improvements.  First, I wanted to make a more realistic “experience” for the players.  I was able to secure a toilet on freecycle (I love freecycle).  After sanitizing it, I set to work wiring up the LED in the bottom of the bowl.  This had the added benefit of making the code simpler.

I also wanted to improve the sound for the game, so I got an inexpensive power amp and car speakers.  I mounted the speakers on the snazzy new platform with locking casters.  This made the whole thing much easier to move around.

Version 3.0

For version 3.0, I wanted to clean things up significantly, and make it easier to assemble/disassemble.  I mounted the amp and Raspberry Pi on a board, that attaches to the inside of the tank with Velcro.  I also used a connector for the sensor instead of being wired to the board.

all components mounted to a single board
I wired up the circuit on a proto hat and added a connector for the LDR so that it was easier to connect/disconnect

Debug mode with monitor and keyboard
What toilet wouldn’t benefit from a debug monitor and keyboard?

Version 3.1

I added a shutdown button for the system so the SD card doesn’t get trashed, and the Pi shuts down gracefully. and covered the wires with some flexible split tubing.  I also added some code to avoid repeating the audio if the sensor detected darkness at the end of the previous audio playback.  Finally, I added some other… apropos sounds.

I bet this is the first time the words “graceful” and “toilet” appear in the same context.

Shutdown button on the Pi Hat
I added a shutdown button. This puts my mind at ease by gracefully shutting down the Pi.

Possible Improvements:

  • I’d like to use the flush handle to perform the shutdown/recalibration

Resources

iTunes Nirvana…

So, I recently added a NAS to the network. I also added a new Mac mini. My goal was to have all the media stored on the NAS and shared it out to all the computers on the network. Since iTunes allows you to share your library, and the ReadyNAS has an iTunes server built-in, I thought this would be a piece of cake.

However, there were a few hiccups that delayed my achieving iTunes Nirvana:

  • You can’t create playlists from iTunes shared libraries
  • FrontRow doesn’t show artwork for items on shared libraries
  • You can’t sync your iPod to a shared library

Clearly, these limitations make the shared library approach less than ideal.

“Ok”, I thought. “I’ll simply point iTunes to the shared volume where the music and the library file reside.”

This didn’t seem to work. No music appeared in the iTunes browser window. After trying several permutations of this arrangement, I gave up.

My last thought was to make a soft link, or “alias” in Mac parlance, to the shared folder and name the alias “iTunes”. I deleted the “iTunes” folder in my home directory, “~/Music/iTunes”, and created the alias there.

The alias points to a mounted shared volume from the NAS

To my surprise, this worked (I really didn’t think it would). The only painful part is that you may have to rebuild your library, losing ratings, etc. However, all the limitations of the shared library are now gone.

I did encounter some issues where iTunes reported a corrupt library file, but I think it was due to my stopping the “importing library” process when I first started iTunes after making the library change (it was late and the import was taking a really, really long time). I also had to “consolidate library” to get some of the content that was local to one of the computers. Another issue I encountered was that startup of iTunes was slow. No biggie. I think the benefit of the remote library outweighs the performance issue. Speaking of performance, the final issue I uncovered was that FrontRow seemed to experience weirdness if iTunes is open. It claimed that there was no content in the library. I quit iTunes, and FrontRow was happy. This may have been due to the delay incurred by the network communication, but it seemed to be related to iTunes being open.
<EOL>

UPDATE: I continued experiencing the weirdness where iTunes on the mini would report a corrupted Library file, and recreate the Library from the Library.XML file (very time-consuming). I suspected this was due to something that the iTunes Helper application was doing. To test this hypothesis, I disabled the helper by selecting (in iTunes) Preferences->Syncing->”Disable automatic syncing for all iPhones and iPods”.

Disable auto-syncing to prevent file sharing violations resulting in Library rebuilds

I think it should be OK to have this enabled on one machine, but I haven’t tested that out. For me, manually syncing my iPod isn’t a big deal.

Also note that you should select “Copy files to iTunes Music folder when adding to library”. Sine your Music folder is on the network now, you’ll want all your content going there.

Be sure to keep all your files in the same place

<EOL>

“Jamcracker? Ewwwww”

My boss forwarded this article about the naming industry (those of you who weathered the dotcom bubble/bust should have just experienced a slight chill).

The article begins as a serious exposition on said industry. Slowly, the reader realizes that the serious treatment was given to set the industry up for mockery. It is definitely worth the read.

At one point, a naming company is caught off-guard when representatives of a client recoil in disgust with the name they’ve been presented, “Jamcracker”.

“There were a couple of women sitting in. One of them got up and said, ‘Oh, that’s disgusting.’ Another said, ‘This is really sick.’ I said, ‘Excuse me, what are you talking about?’ They said, ‘We can’t explain it, but that name is just creeping us out. We don’t know what it is, but could you take it off the wall, please?'” Manning remains mystified by the incident. “There’s apparently some strange, uncomfortable meaning attached to it in the minds of some women,” he says. “God knows what that could be.”

As we discussed the article, we came up with a name for the reaction to the name, “Jamcracker”. We decided to coin the term: “The Jamcracker Effect”. Here, we define “The Jamcracker Effect” as:

the situation wherein a concept is considered distasteful based on the sound of its name, despite the non-distasteful nature of any individual components of the name.

Some examples of the Jamcracker Effect might be:

  • “Meat Waffle”
  • “Street Chicken”

<EOL>

geek haiku #1

I’ve decided to try something new. Geek Haiku or “geeku”. I’m going to try for 1 per week, and in the future more. It’s an exercise in writing and trying to crystallize my thoughts.

cacti is set up
many php errors
timesheet is barren

-誤動作54

did I mention I’m an idiot?

Oh, so the reason for my last post? I’m ashamed to admit this, but here goes…

One of the things that really irked me about Windows® was that there seemed to be no respect for what the user was doing. Popup windows or dialogs always took focus. This annoyed me to no end. Once I started using the Mac, I felt respected. Usually dialogs would pop up, but not take focus. Of course, this has its drawbacks, but it kept with the “OSX stays out of your way” concept that I appreciated.

Unfortunately, not all apps behave this way (Colloquy, I’m looking at you). So this morning, I’m logging in to IRC, and Colloquy pops up a dialog for my password (and it keeps *not* saving it – ugh). so I start typing. I’m not quite a touch typist, so I don’t always look at the screen. Next thing I notice is that an IRC window is up, and I’ve just typed my password into the IRC channel. Gah!!!!

So, I had to go and change passwords and update them in my passwords file. Let the comedy of errors begin.

<EOL>