Danboard is my XFD

2009-04-20 23:23

Recently, I bought and hacked “Danboard mini Amazon.co.jp Box Version”. Now my Danboard is a XFD (eXtreme Feedback Device), which is controlled from Arduino.

Danboard

Hardware

Parts:

Danboard already has two LEDs on the eyes. However it’s white and I want red and green. So I opened Danboard’s head and switched LEDs.

To open the head, You’ll need to remove 2 screws.

Software

Danboard XFD has 3 states:

  1. Green (initial and success)
  2. Red (failed)
  3. Blink (testing)

I wrote a little C++ code for Arduino. It’s so easy because Arduino has very simple C++ library. The below code is reading USB serial and switching 3 states.

int COLOR_LEDS[2][3] = {
    { 3, 5, 6 },
    { 9, 10, 11 },
};
int RED[] = { 0xff, 0, 0 };
int GREEN[] = { 0, 0xff, 0 };

int* Left = GREEN;
int* Right = GREEN;
int Counter = 0;

void colorWrite(int index, int* color) {
    for (int i = 0; i < 3; i++) {
      analogWrite(COLOR_LEDS[index][i], color[i]);
    }
}

void readAndEval() {
    int c = Serial.read();

    switch (c) {
    case 'r':
        Left = Right = RED;
        break;
    case 'g':
        Left = Right = GREEN;
        break;
    case 'B':
        Left  = RED;
        Right = GREEN;
        break;
    }
}

void setup() {
    Serial.begin(9600);
}

void loop() {
    if (Serial.available() > 0) {
        readAndEval();
    }

    colorWrite(Counter & 1, Left);
    colorWrite(!(Counter & 1), Right);
    Counter++;

    delay(200);
}

And I wrote a little wrapper for prove (1).

#! /bin/sh
device='/dev/cu.usbserial-A700651k'
prove='/usr/bin/prove'

echo B > $device
$prove "$*"
if [ $? == 0 ]; then
    echo g > $device
else
    echo r > $device
fi

XFD is usually used for Continuous Integration but prove (1) is not for CI. It’s just a demo :)

Leave a Reply