Introduction: Easter Egg Hunt With Annikken Andee

Hi guys, Easter has just passed and we uploaded a video on a easter project we did. We got some request on how we created this project. It's a fairly simple project with some help from your smartphone and Annikken Andee.

Annikken Andee has hardware and software application working together to create a seamless experience.

An EASTER EGG HUNT!
We slapped together our very own Annikken Andee (iOS) and last night dinner left over to make an Easter Egg Detector!
No eggs will be left undetected.


Step 1: What Will You Need to Start the Project!

Components

1x Arduino Uno 
1x Annikken Andee iOS
1x Egg ( Yolk removed )
3x Resistor (220 ohm)
1x RGB LED

wires, breadboard, bluetack

Tools

IOS Device iPhone, iPad , iPad Mini


Step 2: Putting It Together

The egg is made up of 4 components. Annikken Andee, Arduino Uno, RGB LED and the Egg.

With this few components gathered, let us put them together! I Use coloured wires RED, BLUE, GREEN to represent the colours in the LED and black for ground, I felt it was easier for me to connect the wires.

Step 1) Mount the Arduino Uno onto Annikken Andee
Step 2) Connect the RGB LED to the breadboard.
Step 3) Connect the wires to Andee pin ~13 , ~11, ~10 and black wire to GND.
Step 4) Connect the 3 resistor between the circuit. 
Step 5) I added extra 4 more wires as connector to the LED.( Extra space to lay the egg on the bread board)


Simple as that!  You are done with the hardware portion of the Project! Now let us move on to the software

Step 3: Software and Get Ready to Start the Hunt!

To detect the egg with your smart phone, you will need an App on
your phone first.

Fortunately, Annikken Andee comes with a free app that u can download from
the Apple store for iOS.

Use the Annikken Andee App to scan for your device. Once connected the phone will started searching for the egg.

Hide it in dark places to see the colours change as you get closer. Have fun searching and Happy Eggster everyone!!

Here are the lessons plan we have developed for easy and quick visual information for this project.

Lesson 1: Creating Your First Display Boxes!
Lesson 4: Changing Colours
Lesson 9: Using Buttons to Control LED or Relays
Lesson 20: Use Bluetooth Signal Strength to Control Things

Learn more about Annikken Andee at
http://www.annikken.com/

Where can I download the latest library and firmware?
http://www.annikken.com/getstarted/

Afterwhich, copy this arduino sourcecode and upload to the arduino.


/************************************************************
[Annikken Andee - Easter Egg Hunt]
================
Use Bluetooth Signal Strength to Adjust the RGB LED color
Use TTS to Sing a song!
by Robin Ha <robin@annikken.com>

Check out our Resources section for more information and
ideas on what you can do with the Annikken Andee!
http://resources.annikken.com

Check out our Blog for regular updates and fun!
http://annikken.com/blog
************************************************************/

#include <SPI.h>
#include <Andee.h>

// We'll have a displaybox to show you the Bluetooth signal strength
AndeeHelper displaybox;
AndeeHelper displaybox2;
AndeeHelper button;

AndeeHelper speechObject; // You need to create a speech object for the phone to talk
AndeeHelper btnNotify;


int Signals[10] = {0,0,0,0,0,0,0,0,0,0};
int curSignalPos = 0;

int redPin = 13;
int greenPin = 11;
int bluePin = 10;


char strBuffer[30];
char signalStr[4];
int signalStrength;
int state;

// The setup() function is meant to tell Arduino what to do
// only when it starts up.
void setup()
{
    Andee.begin();  // Setup communication between Annikken Andee and Arduino
    Andee.clear();  // Clear the screen of any previous displays
    setInitialData(); // Define object types and their appearance

    pinMode(redPin,OUTPUT);
    pinMode(greenPin,OUTPUT);
    pinMode(bluePin,OUTPUT);

    Serial.begin(9600);
}

// This is the function meant to define the types and the apperance of
// all the objects on your smartphone
void setInitialData()
{


    displaybox.setId(0);  // Each object must have a unique ID number
    displaybox.setType(DATA_OUT);  // This defines your object as a display box
    displaybox.setLocation(0,0, FULL); // Sets the location and size of your object
    displaybox.setColor(THEME_YELLOW);
    displaybox.setTitleColor("50000000");
    displaybox.setTitle("EASTER HUNT");
    displaybox.setTitleTextColor("FFFFFFFF");
    displaybox.setData("Where is the egg?");

    displaybox2.setId(2);
    displaybox2.setType(DATA_OUT);
    displaybox2.setLocation(1,0,FULL);
    displaybox2.setColor(THEME_ORANGE);
    displaybox2.setTitleColor("50000000");
    displaybox2.setTitle("Egg Detector");
    displaybox2.setUnit("");

    button.setId(6); // Don't forget to assign a unique ID number
    button.setType(BUTTON_IN); // Defines object as a button
    button.setLocation(1,0,FULL);
    button.setTitle("Let's celebrate with Easter Bunny Song!");
    button.setColor("FFFFB6C1");

    speechObject.setId(12);
    speechObject.setType(TTS); // Defines object as a Text-to-Speech object

}
int dcCounter = 3;
bool connection = false;
// Arduino will run instructions here repeatedly until you power it off.
void loop()

{
    if( Andee.isConnected() ) // Run only when connected
    {
        dcCounter = 3;
        if(connection==false){
            connection=true;
            state = 0;
            Andee.clear();
            displaybox.setColor(THEME_YELLOW);
            displaybox.update();
            speechObject.updateData("Welcome to the Easter Egg Hunt!");
            delay(2500);

            displaybox2.setData("Initialising.");

            speechObject.updateData("Egg Detector initializing");
            displaybox2.update();

            delay(700);

            displaybox2.setData("Initialising..");

            displaybox2.update();

            delay(700);
            displaybox2.setData("Initialising...");
            displaybox2.update();
            delay(700);
            displaybox2.setData("Initialising.");
            displaybox2.update();
            delay(700);

            speechObject.updateData("Egg Detector Online");

            displaybox2.setData("< Online >");
            displaybox2.update();
            delay(1500);
        }

        int str = getStrength();
        updateState(str);
        stateToBlinkPattern();
        displaybox.update();
        displaybox2.setData(StateToText());
        displaybox2.update();
        if(state == 6){
            speechObject.updateData("You Have Found the Egg!");
            displaybox2.setData("You have found the egg!");

            displaybox2.update();
            spamRandomBlink(3500);
            displaybox2.remove();
            displaybox.setData("Easter Egg Found");
            displaybox.update();
            button.update();
            speechObject.updateData("Lets Sing a Song to celebrate!");
            while(1){
                setRGB(-1,-1,-1,1000);
                if( button.isPressed() )
                {
                    button.ack();
                    button.requireAck(false);

                    button.setTitle("Singing ~ ~");
                    button.update();
                    speechObject.setUtteranceSpeed(0.65);
                    speechObject.setPitch(1.1);
                    speechObject.updateData("This is the Bunny song, Sing along with me!");
                    speechObject.updateData("You put your right paws in");
                    speechObject.updateData("you take your right paws out");
                    speechObject.updateData("You put your right paws in");
                    speechObject.updateData("and you shake them all about");
                    speechObject.updateData("You do the Bunny Pokey");
                    speechObject.updateData("and you hop . all . around");
                    speechObject.updateData("That's what  ");

                    speechObject.setUtteranceSpeed(0.45);
                    speechObject.updateData("  it's all");

                    speechObject.setUtteranceSpeed(0.35);
                    speechObject.updateData("about!");
                    button.setTitle("Singing ~ ~");
                    button.update();

                    spamRandomBlink(12000);

                    button.ack();
                    button.remove();
                    displaybox.setUnit("By Annikken");
                    displaybox.setData("Happy Easter 2014!!");
                    speechObject.setUtteranceSpeed(0.5);
                    speechObject.setPitch(1.0);
                    speechObject.updateData("Happy Easter");
                    for(int y = 0;y<10;y++){
                        displaybox.setColor(THEME_ORANGE);
                        displaybox.update();
                        spamRandomBlink(1500);
                        displaybox.setColor(THEME_GREEN);
                        displaybox.update();
                        spamRandomBlink(1500);
                        displaybox.setColor(THEME_PURPLE);
                        displaybox.update();
                        spamRandomBlink(1500);

                    }
                }
            }
        }
    }
    else
    {
        if(dcCounter>0)
        {
            dcCounter--;
        }
        if(dcCounter==0){
            connection==false;

        }
    }
    delay(50);
}

int getStrength(){
    Andee.sendCommand("GET RSSI", signalStr);
    signalStrength = atoi(signalStr); // Convert to int value
    Signals[curSignalPos] = signalStrength;
    curSignalPos++;
    if(curSignalPos>=10){
        curSignalPos=0;
    }
    return calAverageStrength();

}
void updateState(int averageStr){
    if(averageStr == 0){
        changeState(0);
    }
    else if (averageStr < -80){
        changeState(1);
    }
    else if (averageStr < -72){
        changeState(2);
    }
    else if (averageStr < -67){
        changeState(3);
    }
    else if (averageStr < -62){
        changeState(4);
    }
    else if (averageStr < -57){
        changeState(5);
    }
    else{
        changeState(6);
    }
}
char * StateToText(){
    if(state == 0){
        return "Calcalating...";
    }
    else if (state == 1){
        return "Still quite far from it";
        displaybox2.setColor("FFFF0000");
    }
    else if (state == 2){
        return "It's getting closer";
        displaybox2.setColor("FF00FF00");
    }
    else if (state == 3){
        return "Within the Vacancy";

        displaybox2.setColor("FF0000FF");
    }
    else if (state == 4){
        return "Around the Corner";
        displaybox2.setColor("FFFF00FF");
    }
    else if (state == 5){
        return "Probably Next to you";

        displaybox2.setColor("FF00FFFF");
    }
    else if (state == 6){
        displaybox2.setColor(THEME_ORANGE);
        return "You have found the egg!";
    }
}
void changeState (int newState){
    if(newState>state){
        state=newState;
    }
}
void stateToBlinkPattern(){

    if(state == 0){
        setRGB(10,10,10,2000);
    }
    else if (state == 1){
        setRGB(255,0,0,2000);
    }
    else if (state == 2){
        setRGB(0,255,0,1500);
    }
    else if (state == 3){
        setRGB(0,0,255,1000);
    }
    else if (state == 4){
        setRGB(255,0,255,1000);
    }
    else if (state == 5){
        setRGB(0,255,255,1000);
    }
    else if (state == 6){
        setRGB(-1,-1,-1,1000);
    }
}

int calAverageStrength(){
    int numberOfValidSignal = 0;
    int TotalStrength;
    for(int x = 0;x<10;x++){
        if(Signals[x]!=0){
            TotalStrength = TotalStrength + Signals[x];
            numberOfValidSignal ++;
        }
    }
    if(numberOfValidSignal==0){
        return 0;
    }
    else{
        int str = TotalStrength/numberOfValidSignal;
        return str;
    }
}
int LR = 0;
int LG = 0;
int LB = 0;
float stepsize_R = 0;
float stepsize_G = 0;
float stepsize_B = 0;
void spamRandomBlink(int duration){
    for (int x  = (duration)/(400);x>=0;x--){
        setRGB(-1,-1,-1,2000);
    }
}
void setRGB(int R, int G, int B,int uDelay){
    if(R==-1){
        R = random(100,255);
    }
    if(G==-1){
        G = random(100,255);
    }
    if(B==-1){
        B = random(100,255);
    }

    stepsize_R = (float)(R-LR)/(float)200;
    stepsize_G = (float)(G-LG)/(float)200;
    stepsize_B = (float)(B-LB)/(float)200;

    for(int x = 1;x<201;x++){
        analogWrite(redPin, LR+(x*stepsize_R));
        analogWrite(greenPin, LG+(x*stepsize_G));
        analogWrite(bluePin,LB+(x*stepsize_B));
        delayMicroseconds(uDelay);
    }
    LR=R;
    LG=G;
    LB=B;
}



Egg Contest

Participated in the
Egg Contest