Moosetar (Zoltar) Fortune Teller
This is an animatronics project where I took a toy moose (it was a Christmas decoration that sang "Blue Christmas") and turned it into Moosetar the fortune telling moose. The moose takes a coin, talks, kind of dances, and prints out a fortune. This may look complicated, but it was fairly easy.

Step 1: Parts

Moosetar (Zoltar) Fortune Teller
  • Toy that talks using DC motors (in my case I chose a singing Christmas moose).
  • Arduino (I used a Mega)
  • Adafruit Motor Shield
  • Emic2 text to speach module
  • Coin Acceptor (I used this one https://www.sparkfun.com/products/11719)
  • Bag to catch coins
  • Connection wire
  • Thermal Printer (I used this one https://www.sparkfun.com/products/10438)
  • A few power supplies
  • A USB mini plasma ball
  • A USB hub
  • Power Strip
  • A basketball display case (I used this one http://www.containerstore.com/shop/collections/display/cubesCases?productId=10001589&N=233)
  • Some wood for the case (I made mine about 5 ft tall, you can make yours whatever height you'd like)
  • Trim for the case
  • Wood Glue
  • Screws
  • Hinge
  • Paint

    Step 2: Control the Toy

    Moosetar (Zoltar) Fortune Teller
    Moosetar (Zoltar) Fortune Teller
    The Moose I used had two motors, on that controls the mouth and the second controls side to side movement (kind of dancing) the moose does. All you need to do is cut the wires that connect to the controller, and connect them to the motor shield. It probably won't matter which wire you connect to ground and power, even though it will change your sketch. I connected my motors to M1 and M2. I also connected a 9v power supply to drive poser to the motors. The motor shield comes with a good example sketch (MotorParty) for driving motors. Try that to verify you can move the motors as you'd like. Here are the important parts:

    Choose the motor to move:
    AF_DCMotor motor(2);

    Releases the motor:
    motor.setSpeed(200);
    motor.run(RELEASE);

    Run the motor Forward:
    motor.run(FORWARD);

    Run the motor Backward:
    motor.run(BACKWARD);
    motor.setSpeed(i);

    This will give you an idea of how you need to run the motors to make the do what you want.

    Step 3: Coin Acceptor

    Moosetar (Zoltar) Fortune Teller
    Moosetar (Zoltar) Fortune Teller
    I used this coin acceptor from Sparkfun https://www.sparkfun.com/products/11719 . The coin acceptor uses pulse width modulation to tell you what coin is sent over. To keep things simple I just used an interrupt on one of the interrupt pins to detect any signal coming over. I also connected the power to a DC power supply and also connected the ground to ground on the Arduino. Another option is use this coin acceptor https://www.sparkfun.com/products/11636 that can send serial data.

    Important parts of the final sketch that relate to the coin acceptor (the white "coin" wire is connected to pin 21

    coin is a global variable, if it's 1 in loop then I know a coin has come through and it should give a fortune

    In setup I did this to create the interrupt:
    attachInterrupt(2, sendcoin, RISING);

    Here's my sendcoin function
    void sendcoin()
    {
    type += 1;
    unsigned long curTime = millis();
    if ((curTime - time) > 50)
    {
    coin = 1;
    }
    else
    {
    coin = 2;
    }
    time = curTime;
    }


    in loop I do this:

    detachInterrupt(2); // this makes sure we don't get a lot of interrupts if people put a bunch of coins in, this could mess up the serial printer trying to print

    At the end of loop() I set coin to 0 and re-attach the interrupt:
    coin = 0;
    attachInterrupt(2, sendcoin, RISING);

    That's basically it for the coin accepting code.


    Step 4: Serial Printer

    Moosetar (Zoltar) Fortune Teller
    Moosetar (Zoltar) Fortune Teller
    Moosetar (Zoltar) Fortune Teller
    I used this serial printer https://www.sparkfun.com/products/10438

    I used Serial1 on the Mega to talk to the printer, the relevant pieces of code are:

    Serial1.begin(19200);

    I have several helper methods to run the printer and print images, etc:

    For the most part I just write to the serial port like this:
    Serial1.print(" Moosetar Says: BEWARE!");

    For printing images I do this:
    printBitmap(moose_outline_width, moose_outline_height, moose_outline_data, true);
    and include the data as a .h file. More information on how to do this can be found here http://learn.adafruit.com/mini-thermal-receipt-printer/bitmap-printing

    Which then get's printed by the printer. I found some helper methods in Lady Ada's library. Because I was using hardware serial I had some issues with her code, but I changed them and included them in the sketch. Here are the relevant methods.


    void writePrintMode()
    {
    Serial.println(printMode);
    Serial1.write(27);
    Serial1.write(33);
    Serial1.write(printMode);
    }

    void setPrintMode(uint8_t mask)
    printMode

    void setNormalMode()
    {
    printMode = 0;
    writePrintMode();
    Serial1.write(27);
    Serial1.write(45);
    Serial1.write(zero);
    Serial1.write(27);
    Serial1.write(32);
    Serial1.write(zero);
    Serial1.write(29);
    Serial1.write(33);
    Serial1.write(zero);
    }

    void unsetPrintMode(uint8_t mask)
    {
    printMode &= ~mask;
    writePrintMode();
    }


    void printerLineFeed(int lines)
    {
    for(int i = 0; i < lines; i++)
    {
    Serial1.write(10);
    }
    }

    void writeBytes(uint8_t a) {
    Serial1.write(a);
    }

    void writeBytes(uint8_t a, uint8_t b) {
    Serial1.write(a);
    Serial1.write(b);
    delay(300);
    }

    void writeBytes(uint8_t a, uint8_t b, uint8_t c) {
    Serial1.write(a);
    Serial1.write(b);
    Serial1.write(c);
    delay(300);
    }

    void writeBytes(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
    Serial1.write(a);
    Serial1.write(b);
    Serial1.write(c);
    Serial1.write(d);
    delay(300);
    }

    void printBitmap(Stream *stream) {
    uint8_t tmp;
    uint16_t width, height;

    tmp = stream->read();
    width = (stream->read()
    tmp = stream->read();
    height = (stream->read()
    printBitmap(width, height, stream);
    }

    void printBitmap(int w, int h, Stream *stream) {
    int rowBytes, rowBytesClipped, rowStart, chunkHeight, x, y, i, c;

    rowBytes = (w + 7) / 8; // Round up to next byte boundary
    rowBytesClipped = (rowBytes >= 48) ? 48 : rowBytes; // 384 pixels max width

    for(rowStart=0; rowStart < h; rowStart += 255) {
    // Issue up to 255 rows at a time:
    chunkHeight = h - rowStart;
    if(chunkHeight > 255) chunkHeight = 255;

    writeBytes(18, 42, chunkHeight, rowBytesClipped);

    for(y=0; y < chunkHeight; y++) {
    for(x=0; x < rowBytesClipped; x++) {
    while((c = stream->read()) < 0);
    Serial1.write((uint8_t)c);
    }
    for(i = rowBytes - rowBytesClipped; i>0; i--) {
    while((c = stream->read()) < 0);
    }
    }
    //timeoutSet(chunkHeight * dotPrintTime);
    }
    //prevByte = '\n';
    }


    void printBitmap(
    int w, int h, const uint8_t *bitmap, bool fromProgMem) {
    int rowBytes, rowBytesClipped, rowStart, chunkHeight, x, y, i;

    rowBytes = (w + 7) / 8; // Round up to next byte boundary
    rowBytesClipped = (rowBytes >= 48) ? 48 : rowBytes; // 384 pixels max width

    for(i=rowStart=0; rowStart < h; rowStart += 255) {
    // Issue up to 255 rows at a time:
    chunkHeight = h - rowStart;
    if(chunkHeight > 255) chunkHeight = 255;

    writeBytes(18, 42, chunkHeight, rowBytesClipped);

    for(y=0; y < chunkHeight; y++) {
    for(x=0; x < rowBytesClipped; x++, i++) {
    Serial1.write(fromProgMem ? pgm_read_byte(bitmap + i) : *(bitmap+i));
    }
    i += rowBytes - rowBytesClipped;
    }
    //timeoutSet(chunkHeight * dotPrintTime);
    }
    //prevByte = '\n';
    }

    Step 5: Emic2

    Moosetar (Zoltar) Fortune Teller
    I tried a couple of ways to get the moose to talk. First I used a second Arduino with a Wave Shield from Adafruit. Then I decided to go with an Emic2 text to speech unit. This worked really well and made it kind of funny since it sounds a bit like a robot. Also I liked this better than the Wave Shield because I didn't have to pre-record anything and I could easily have it say whatever I wanted.

    I got mine here https://www.sparkfun.com/products/11711 but you can also order them directly from Parallax or a bunch of other places. Basically you send it serial commands and it will talk. Here are the important parts of the sketch:

    Define the software serial interface I used:
    #define rxPin 51 // Serial input (connects to Emic 2 SOUT)
    #define txPin 53 // Serial output (connects to Emic 2 SIN)
    SoftwareSerial emicSerial = SoftwareSerial(rxPin, txPin);

    In setup() we get ready to talk to the Emic2
    emicSerial.begin(9600);
    emicSerial.print('\n'); // Send a CR in case the system is already up
    while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
    delay(10); // Short delay
    emicSerial.flush(); // Flush the receive buffer

    I used the following method to take some text, send it to the Emic2 and run the moose mouth and body while it talked:
    void mooseTalk(String phrase)
    {
    emicSerial.println("P1");
    delay(100);
    clearEmicSerialRead();
    emicSerial.println("W75");
    delay(100);
    clearEmicSerialRead();
    emicSerial.println("V0");
    delay(100);
    clearEmicSerialRead();
    emicSerial.println("N0");
    delay(100);
    clearEmicSerialRead();
    emicSerial.print('S');
    //emicSerial.print("\\/\\/");
    emicSerial.println(phrase);
    Serial.println(phrase);

    int i = 0;
    int u = 0;
    for(int j = 0; j < phrase.length(); j++)
    {
    if(phrase[j] == ' ')
    {
    i++;
    }
    if(phrase[j] == '_')
    {
    u++;
    }
    }

    i = i + u/2;
    i = i - i * .25;
    delay(300);
    for(int j = 0; j < i; j++)
    {
    mooseMove(random(250,450));
    delay(random(150,300));
    }
    clearEmicSerialRead();
    //while (emicSerial.available() > 0)
    //{
    //Serial.println(emicSerial.read());
    //}
    //while (emicSerial.read() != ':');
    }

    I also created this method to have it sing after it gave it's fortune. The songs in the sketch are "hit me with your best shot", "Edelweiss", and "Daisy Bell"

    void singSong() {
    emicSerial.println("V0");
    delay(100);

    emicSerial.println("P0");
    int song = random(3);
    if (song == 0)
    {
    emicSerial.println("S[:rate 230][:n0][:dv ap 200 sm 100 ri 100][WEHLXYXORAHAXRIYLLTAHFKUHKIYWIHTHAXLLAONXHXIHSTORIY_ AHV BRREYK AHNLLIHDXELHXARTSLLAYKDHAXWAHN IHNMIY_DHAETSOWKEYLLEHTSSIYHXAWYUDUWIHT_PUHTAHPYXORDUWKSLLEHTSGEHTDAWNTUWIHTHXIHTMIYWIHTHYXORBEHSTSHAOT_WAYDOWNCHAXHXIHTMIYWIHTHYXORBEHSTSHAOAOT_HXIHTMIYWIHTHYXORBEHSTSHAOT_FAYRRAXWEHEY][:n0]");
    for(int i = 0; i < 22; i++)
    {
    mooseMove(random(500,1450));
    delay(random(150,300));
    }
    clearEmicSerialRead();
    }
    else if(song == 1)
    {
    emicSerial.println("S [:phone arpa speak on][:rate 180][:n0][:dv hs 95 br 0 as 90 ap 90 sm 90 ri 100][EYDELVAYSEYDELVAYSEHVRIYMORNIHNXYUGRIYTMIY_SMAOLXAENDWAYTKLLIYNAENDBRAYTYULLUHKHXAEPIYTUWMIYTMIY_BLLAOSAHMAHVSNOWMEYYUBLLUWMAENDGROW_BLLUWMAENDGROWFOREHVRR_EYDELVAYSEYDELVAYSBLLEHSMAYHXOWMLLAENDFOREHVRR][:n0]");
    for(int i = 0; i < 40; i++)
    {
    mooseMove(random(500,1450));
    delay(random(150,300));
    }
    clearEmicSerialRead();
    }
    else //if (song == 2)
    {
    emicSerial.println("D1");
    for(int i = 0; i < 22; i++)
    {
    mooseMove(random(500,1450));
    delay(random(150,300));
    }
    clearEmicSerialRead();
    }
    /*else
    {
    emicSerial.println("S [:phone arpa speak on][:rate 190][:n2][:dv ap 200 sm 100 ri 100][R EYNDRAOPSAONROWZIXZAENDWIHSKRRZAONKIHTAHNZ_BRAYTKAOPRRK EHTELZAENDWarMWUHLL EHNMIHTAHNZ_BRAWNPEYPRRPAEKIHJHIXZTAYDAHPWIHTHSTRIHNXZ_DHIYZARAXFYUAHVMAYFEYVRREHTTHIHNXZ][:n0]");
    emicSerial.println("S [:phone arpa speak on][:rate 190][:n2][:dv ap 200 sm 100 ri 100][KRIY M KAH LLRR D POW NIY Z AE N D KRIH SP AE PEL STRUW DXEL _ DOR BEH LX Z AE N D SLLEY BEH LX ZAE N D SHNIH T SEL WIH TH NUW DXEL Z _WAY LL D GIY S DHAE T FLLAY WIH TH DHAX MUW N AO N DHER WIH NX Z _DHIY Z AR AX FYU AH V MAY FEY VRR EH T THIH NX Z][:n0]");
    emicSerial.println("S [:phone arpa speak on][:rate 190][:n2][:dv ap 200 sm 100 ri 100][GRR LL Z IH N WAY T DRREH SIX Z WIH TH BLLUW SAE TAH N SAE SHIX Z _ SNOW FLLEY KS DHAE T STEY AO N MAY NOW Z AE N D AY LLAE SHIX Z _SIH LL VRR WAY T WIH N TRR Z DHAE T MEH LL T IH N TUW SPRIH NX _ DHIY Z AR AX FYU AH V MAY FEY VRR EH T THIH NX Z _][:n0]");
    emicSerial.println("S [:phone arpa speak on][:rate 190][:n2][:dv ap 200 sm 100 ri 100][WEH N DHAX DAO G BAY TS _ WEH N DHAX BIY STIH NX Z _ WEH N AY M FIY LLIH NX SAE D AY SIH M PLLIY RIY MEH M BRR MAY FEY VRR EH T THIH NX Z AE N D DHEH N AY DOW N T FIY LX _ SOW BAE D_][:n0]");
    clearEmicSerialRead();
    for(int i = 0; i < 180; i++)
    {
    mooseMove(random(500,1450));
    delay(random(150,300));
    }
    }*/
    clearEmicSerialRead();

    emicSerial.println("P1");
    clearEmicSerialRead();

    }

    Step 6: Making the Sound and Movements Work Together

    Moosetar (Zoltar) Fortune Teller
    Moosetar (Zoltar) Fortune Teller
    This was an interesting, kind of automated puppetry part I though was interesting. I didn't want to have to code out a sequence of opening and closing his mouth for every different bit of text he would say. Instead I wanted a method that could figure out how it could open his mouth. I found by parsing the incoming string and looking for spaces and __ (double underscores, which emphasize words) I could figure out how to open his mouth. For singing I did basically the same thing, but I just opened his mouth longer. Here's the revelvant code:

    for(int j = 0; j < phrase.length(); j++)
    {
    if(phrase[j] == ' ')
    {
    i++;
    }
    if(phrase[j] == '_')
    {
    u++;
    }
    }

    i = i + u/2;
    i = i - i * .25;
    delay(300);
    for(int j = 0; j < i; j++)
    {
    mooseMove(random(250,450));
    delay(random(150,300));
    }

    As you can see I take the number of spaces, add half the number of underlines, then subtract 25%. In almost every case he opens his mouth very close to what was being said by the Emic2. I used random delays when opening and closing his mouth to make it seem a bit more real. I also did some little back and forth dancing moves when the printer was going and he wasn't talking.

    Step 7: Wooden Case

    Moosetar (Zoltar) Fortune Teller
    I kept the case pretty simple. The basketball enclosure I was using was about 10" x 10", so I cut the wood to be the same size so it could sit right under it. For part of the box I used MDF, which worked well, for the other (lower) section I used pine The nice thing about MDF is there are no spliters, and it's pretty cheap. I'm not sure it would survive a good kick though. I used both glue and screws to hold the sides together to make the box. I painted the whole thing black with spray paint. I cut a door in the back and connected hinges so I could open it.

    I drilled a couple of holes in the bottom of the enclosure and screwed them onto the wooden box I built. I put trim around the top section and some around the middle with the two parts of the stand come together. I cut a 2" by 4" hole towards the back of the basketball enclosure for the moose to come up through.

    Last I ran the USB plasma ball cord through the hold the moose was coming through. I connected to other side to a USB hub that was powered off a cell phone charger. I connected the Arduino to the same USB hub.

    Step 8: Stickers and decorations

    Moosetar (Zoltar) Fortune Teller
    Moosetar (Zoltar) Fortune Teller
    To decorate the box I got some red felt and some gold rope to give him a backdrop. I also got some shiny scrapbooking paper on the back wall and bottom of the basketball enclosure.

    I went to a craft store and got letters to put on the front of the basketball enclosure to say "Moosetar". I also put a sign that said pull up because the printer doesn't rip as well pulling down.

    Step 9: Video and code

    Moosetar (Zoltar) Fortune Teller
    Here's a video of moosetar working. As you can see you put a coin in, then it talks and gives you a fortune, then you rip it off. I've attached the code here. The .h files are different images of moose

    This is an early video before it was painted and used the Emic2


    Here's with the Emic2
    Moosetar (Zoltar) Fortune Teller
    talkingMooseDemo.zip17 KB
  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel