Pages

SparkFun: BadgerHacked

Every year, Austin (Texas) has an event for makers, tinkerers, and other nerds who like to build. It’s called SXSW Create. This year, I was manning a booth with The Robot Group. Sparkfun Electronics was giving away these little badges:

Image courtesy learn.sparkfun.com.

They gave you a bag of parts and you waited until there was a soldering station open. Then you just soldered the headers on, threw in some batteries, attached a lanyard, and you had a microcontroller around your neck.

They said they were reprogrammable, so I decided to turn mine into a name tag.

I investigated and found the support files. The page containing them and the installation instructions can be found here. Then I downloaded the Arduino IDE, which will allow us to reprogram the Badger.

I initialized the LED matrix:

#include <SparkFun_LED_8x7.h>
#include <Chaplex.h>

// Global variables
static byte led_pins[] = {2, 3, 4, 5, 6, 7, 8, 9}; // Pins for LEDs

void setup() {

  // Initialize LED array
  Plex.init(led_pins);

  // Clear display
  Plex.clear();
  Plex.display();
}

Next I looked at Sparkfun_LED_8x7.h. (.h files are to .cpp files what tables of contents are to books.) I found the scrollText() method and the stopScrolling() method. I messed around for a bit and found that I need to scrollText(), wait for a bit, then stopScrolling().

In loop(), I made the text “The Robot Group” scroll across the screen.

  Plex.scrollText("The Robot Group", 1);
  delay(10000);
  Plex.stopScrolling();
  delay(2000);

Then I poked around a bit more and found the drawing methods. I prefixed the text with a very pixellated version of the group’s logo.

  // Logo
  Plex.clear();
  
  // Logo: Circle
  Plex.line(2, 0, 0, 2);
  Plex.line(0, 2, 0, 4);
  Plex.line(0, 4, 2, 6);
  Plex.line(2, 6, 5, 6);
  Plex.line(5, 6, 7, 4);
  Plex.line(7, 4, 7, 2);
  Plex.line(7, 2, 5, 0);
  Plex.line(5, 0, 2, 0);
  
  // Logo: Man
  Plex.line(1, 7, 3, 3);
  Plex.line(6, 7, 4, 3);
  Plex.line(0, 2, 7, 2);
  Plex.line(4, 1, 3, 1);
  
  // Logo: Display for 5 seconds
  Plex.display();
  delay(5000);

The Robot Group’s logo:

The Robot Group's logo.

The Robot Group’s logo.

BadgerHack version:

And so I reprogrammed my badge and then did likewise with some of the other members’ badges. It was quite entertaining for me.

Here is the finished code. BadgerStickTRG.zip

Leave a Reply