Arduino Game Of Life on 8×8 LED Matrix

I was messing around with some Christmas toys and threw together a Conway’s Game Of Life implementation together on my Arduino.  I just love how quick it is to get things up and running on this platform.  It took me longer to solder a platform for the LED matrix to raise it up off the breadboard so the wires would all fit than the whole rest of the project.

Here’s a video of Arduino Game Of Life running.

Anyway, more pictures and full source code are below.  The code has a couple of conditionally compiled options, one for storing rand seeds to EEPROM.  With the randomization turned on, every so often I’d see a “game” that progressed really nicely.  I wanted to be able to go back and watch the same game again.

Read more »


How To Selectively Delete Photos Off iPhone?

To spread some knowledge I found really helpful, this thread contains the answer to the question.  The iPhoto app will let you delete all downloaded images, but I wanted to delete a select range (some big videos in particular).  The short version: quit iPhoto, launch Image Capture, click Download Some…, select photos to delete, and delete from the edit menu.  Done.  Thanks FloBro!


PHP 5.3 + XDebug + NetBeans + Mac OSX Leopard

… or how I got all the toys to play nice together …

If you’re working in PHP and are echoing out your variables to see what’s going on, please stop that right now.  Graphical Debuggers are here (in fact, they’ve been here for some decades) and now they work really nicely with free IDE tools.  Here I’ll outline how to get graphical PHP debugging with NetBeans working. The overview is: (1) install PHP 5.3, (2) install Xdebug, (3) install NetBeans, (4) configure publishing path, (5) test Xdebug.

There’s a lot more to go through. Click through to see all the steps…
Read more »


More natural BDD with PHPUnit

I’ve always been a little jealous of RSpec.  Those Ruby kids and their natural language BDD testing and plain text stories…  It always just seems more awkward any other way.  Cucumber looks pretty cool but getting it to play nicely with PHP is a little over my KISS threshold today.

Well, PHPUnit does have an alternative in its Story extension.  Look at the docs and it’s simple enough to put into effect, and works nicely as part of a bigger set of unit tests.  But check out how those scenarios are constructed – the argument passing just doesn’t seem elegant, and run phpunit --story <file> on the 2-arg puppies and it’s not pretty at all. Here’s a simple scenario straight from the manual:

    /**
     * @scenario
     */
    public function scoreForOneStrikeAnd3And4Is24()
    {
        $this->given('New game')
             ->when('Player rolls', 10)
             ->and('Player rolls', 3)
             ->and('Player rolls', 4)
             ->then('Score should be', 24);
    }

So how can we write PHPUnit scenarios to read more like natural language?   Well, first thing to go are the arguments.  I’d rather write:

    /**
     * @scenario
     */
    public function scoreForOneStrikeAnd3And4Is24()
    {
        $this->given('New game')
             ->when('Player rolls 10')
             ->and('Player rolls 3')
             ->and('Player rolls 4')
             ->then('Score should be 24');
    }

Not a huge change, but it takes a little more work to finish the plumbing. Just looking at implementing the when clause, the original version read

    public function runWhen(&$world, $action, $arguments)
    {
        switch($action) {
            case 'Player rolls': {
                $world['game']->roll($arguments[0]);
                $world['rolls']++;
            }
            break;

            default: {
                return $this->notImplemented($action);
            }
        }
    }

and ends up becoming something like:

    public function runWhen(&$world, $action, $arguments)
    {
        switch(true) {
            case preg_match('/^Player rolls \d+$/', $action): {
                $world['game']->roll( preg_replace('/\D/', '', $action) );
                $world['rolls']++;
            }
            break;

            default: {
                return $this->notImplemented($action);
            }
        }
    }

I feel like the added complexity of the helper code is compensated by the much more natural and flexible way you can construct the scenarios.  Start adding multiple arguments to the clauses and it’s even nicer.


ATtiny13 Dice

dice I wanted to learn how to get the handful of non-Arduino AVR chips I have working.  I wanted to learn the basics of the C API, the development toolchain, and get a sense for what can be done with the little ATtiny microprocessors.  Starting with the most limited, teeny tiny little chip (the 1k ATtiny13), I made a dice.
Read more »