Big Red (usb) Button04 Oct 2011
A few weeks ago, Ben was putting together a proof-of-concept for what turned into the MQTT powered video wall. He needed a button to trigger the publishing of an MQTT message. We happened to have a Staples Easy Button lying around that was ripe for the hacking.
A short time spent with scalpel and soldering iron and I had a pair of wires sticking out the bottom of the button that could be plugged into an arduino; which was good enough for Ben’s demo.
But then this week Dale was wanting a button to use as a part of a Watson talk next week. Rather than just hand him the button, an arduino and a guide to wiring them together, I decided to be more helpful.
I knew the base of the button had some empty space once the batteries and speaker were removed and I had a spare Freeduino Nano awaiting a project, so it was back to the scalpel and, this time, hot glue gun.
So we now have a button with a usb connection that can plug straight into a laptop to do stuff. Unlike RIG’s Big Red Button it doesn’t emulate a keypress as it doesn’t appear as a HID device to the laptop - I’ll save that for another day.
At the moment, the sketch on the arduino simply writes ‘hit’ to the serial port when the button is pressed, so it needs something to run on the laptop to get the message and act accordingly. Which is trivial enough with python:
import serial PORT="/dev/ttyUSB0" def buttonPressed(): print "Do your magic here" s = serial.Serial(port=PORT, baudrate=9600) while True: l = s.readline() if l[:3] == 'hit': buttonPressed()