Hacking Home Depot Lethal Lily animatronic – part 2

See Also: intro, part 1, part 2, part 3 and part 4. (Github project.)

WARNING: I am not a hardware person. I’m just a programmer that knows “enough to be dangerous.” I have not measured the voltage/signals coming out of the Control Box to see if they are safe to connect to an Arduino UNO like this. What I am doing could fry the Arduino and/or the Control Box. I don’t know. Consult someone who knows hardware to find out what I am possibly doing wrong…

This article series is a “stream of consciousness” post. I describe the steps as I am working through them. There will be dead-ends, where I learn something new, so try not to scream at your screen when you see me doing something dumb. ;-)

Control Box, meet Arduino UNO…

I used some header/jumper cables (male to female) to go from the four-pin connector’s green wire to an Arudino digital pin (I chose pin 13 since it is next to a ground pin), and the four-pin connector’s black wire to an Arduino ground pin.

Control Box  Arduino UNO
=========== ===========
Blue ------- PIN 13
Black ------ GND
Red not connected
Green not connected
Lethal Lily control box to Arduino.

In the above photo you will see I also have the blue wire also connected, but it is currently not hooked to the Arduino. You only need the green and black Control Box wires going to Arduino I/O and GND pins.

Here is my code, which uses SoftwareSerial to turn PIN 13 (picked only because it was next to the ground pin) in to an RX (receive) serial port pin. The code then loops waiting for a byte to be written by the Control Box. Since I now see that the pattern is four-bits/four-bits-inverted, I even added a bit of code that ANDs each of those four bits together. The result should be zero if it is a valid byte from the Control Box. (This could be done a bit better since now I know the acceptable values are only 1-8, but this is good for a quick test.)

I then print out the byte value in HEX and as binary, and if it’s value is not 8, I print “PLAYING#” and parse out the 3-bit number (1-7). If it is 8, then I print “STOPPED” since that marks the end.

Lather, rinse, repeat… Here is my code:

#include <SoftwareSerial.h>

// RX pin connected to GREEN wire.
// TX pin not used.
SoftwareSerial mySerial(13, 3); // RX, TX


void setup() {
// Arduino console port.
Serial.begin(9600);
while (!Serial);

// Control box sends at 550baud.
mySerial.begin(550);

Serial.println("Running...");
}

void loop()
{
unsigned char ch;

// put your main code here, to run repeatedly:
while (mySerial.available())
{
// Read byte from Control Box.
ch = mySerial.read();

Serial.print ("[");
Serial.print (ch, HEX);
Serial.print (" - ");
Serial.print (ch, BIN);
Serial.print ("] ");

// Validate. Left nibble AND with right nibble should be zero.
if ( ((ch & 0xf0 >> 8) & (ch & 0x0f)) != 0)
{
Serial.println ("INVALID.");
}
else
{
if (ch & 0b1000)
{
Serial.println ("STOPPED.");
}
else
{
Serial.print ("PLAYING #");
Serial.print (ch & 0x0f);
Serial.print (" ... ");
}

}
}
}

// End of file.

Running that, then triggering the sensor, produces the following output:

Running...
[92 - 10010010] PLAYING #2 ... [F8 - 11111000] STOPPED.
[83 - 10000011] PLAYING #3 ... [F8 - 11111000] STOPPED.
[74 - 1110100] PLAYING #4 ... [F8 - 11111000] STOPPED.
[65 - 1100101] PLAYING #5 ... [F8 - 11111000] STOPPED.
[16 - 10110] PLAYING #6 ... [F8 - 11111000] STOPPED.
[7 - 111] PLAYING #7 ... [F8 - 11111000] STOPPED.
[E1 - 11100001] PLAYING #1 ... [F8 - 11111000] STOPPED.
[92 - 10010010] PLAYING #2 ... [F8 - 11111000] STOPPED.

If we can read those bytes, we should be able to send them to the head :)

And now on to the hard part… that blue wire and the pulses that control the servos (or so I suspect at this point).

To be continued…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.