Posts Tagged ‘blinkm’

DIY Ambient Orb: Redux

Tuesday, November 25th, 2008

Orb

Orb Base

RJ11

/************************************************
 * Enables a BlinkM to be controlled over MQTT.
 *  - subscribes to the topic 'blinkm'
 *  - expects messages of the format 'RRGGBB'
 *  - doesn't do any error handling
 *
 *    Nicholas O'Leary
 *    http://knolleary.net
 ************************************************/
#include <Wire.h>
#include <Ethernet.h>
#include <PubSubClient.h>
#include <BlinkM_funcs.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 172, 16, 0, 50 };
byte server[] = { 172, 16, 0, 100 };

void callback(char* topic, byte* payload,int length) {
  byte a = toHex( payload[0],payload[1] );
  byte b = toHex( payload[2],payload[3] );
  byte c = toHex( payload[4],payload[5] );
  BlinkM_fadeToRGB( 0x09, a,b,c);
}

PubSubClient client(server, 1883, callback);

void setup()
{
  BlinkM_beginWithPower();
  BlinkM_setAddress( 0x09 );
  BlinkM_stopScript( 0x09 );

  Ethernet.begin(mac, ip);

  if (mqttClient.connect("blinkr")) {
    mqttClient.subscribe((uint8_t*)"blinkm");
  }
}

void loop()
{
  mqttClient.loop();
  delay(500);
}

// a really cheap strtol(s,NULL,16) - taken from BlinkMTester
#include <ctype.h>
uint8_t toHex(char hi, char lo)
{
    uint8_t b;
    hi = toupper(hi);
    if( isxdigit(hi) ) {
        if( hi > '9' ) hi -= 7;
        hi -= 0x30;
        b = hi<<4;
        lo = toupper(lo);
        if( isxdigit(lo) ) {
            if( lo > '9' ) lo -= 7;
            lo -= 0x30;
            b = b + lo;
            return b;
        }
    }
    return 0;
}

DIY Ambient Orb

Saturday, July 19th, 2008

Take one garden light bought at M&S for £3.50 and dissect it:

Dissected Ambient Light

Connect a BlinkM up to an arduino and set it running:

BlinkM

Combine the two and you have a home-brew ambient orb:

Next step, do something interesting with it.

I’ve been on the lookout for suitable materials to make an ambient orb for a while - particularly something to diffuse the light. My original plan, which I may still do, was to take an ordinary lightbulb and put an RGB led inside it. However, modern lightbulbs prove quite tricky to take apart without shattering something. When I spotted these lights in M&S last week I knew they were exactly what I wanted. So I bought three.

They were pleasingly easy to dissect - just some gentle persuasion with a craft knife. The led’s they come with, which you can see here, are going to be handy to reuse in the future.

I still need to work out how best to mount the BlinkM beneath it. Given their I2C interface, it is going to be very easy to chain lots of them together, working as a group.

Ambient orbs are fascinating interfaces - they provide an abstraction that can convert an data source into a simplified, yet powerful, source of information.

Converting data into information is something I have been meaning to write about for a while. But given it’s my wife’s birthday and we’re heading out for the evening in 5 minutes, that post will have to wait for another day.