Created: February 3rd, 2015

0

Scenario

Our project attempts to provide an avenue for two people to communicate their inside jokes to each other. Imagine two siblings that were taught from a young age that anyone who has a mustache is a possible abductor. The idea that men with mustaches pose a higher likelihood of abducting people has become something of an inside joke to the two siblings. When they are together at the mall and see a man with a mustache they nudge each other and let the other one know about the person they just saw. They have shared a moment together that they both have a history with and share a laugh about the situation.

Or consider the tradition that many people have of when they see a vehicle with one headlight out they two race to yell “padiddle” to each other. Meaning is conveyed by the use of the term padiddle that both of the people understand, namely that they have just seen a vehicle that only has one headlight.

Our platform allows the people above to share this moment with each other even when they are not together by flashing a color of light to the other person’s device. The two people can set up one of the three colors to correspond with one of their inside jokes. 

Now, when one sister is strolling down Rodeo Drive in Los Angeles and sees an awkward looking man with a mustache, she can send a nudge to her sister on Fifth Avenue in New York and both can smile knowing that they have grown closer through the experience. This facilitates a sense of connection through the cloud even though they are separated by thousands of miles.

Process

Firstly we brainstormed a lot of ideas for couples, entertainment and friends. We decided to use objects that are for daily uses so we can add functionality and fun onto it. At first we chose joystick as our controller to control but we found out that it takes a lot of time for coding in joystick since we have to define in two-dimension way. Then we used potentiometer as our color controller, which is simple and small size, and a button to send inside-jokes. The object for our final decision is a keychain so that users can bring it everyday.

Components

2 SparkCores

2 breadboards

2 Potentiometers

2 RGB LEDs

6 1k Ω resistors

2 push buttons

Lots of jumpers

0
int redPin = A0;
int greenPin = D0;
int bluePin = D1;

// Define a pin that we'll place the pot on
int potPin = A1;
//send to internet
int buttonPin = D2;

// Create a variable to hold the pot reading
int potReading = 0;

// Create a variable to store color state.
int state = 0;

void setup(){

  pinMode( redPin, OUTPUT);
  pinMode( greenPin, OUTPUT);
  pinMode( bluePin, OUTPUT);
  pinMode( buttonPin , INPUT_PULLUP); // sets pin as input

  Spark.subscribe(  "db2015/conchain123/color1" , receiveColor );

}



void loop() {



  // when the button is not pushed we'll get a HIGH
  //first set color off (255,255,255)

  potReading = analogRead(potPin);
  //map the color state
  state = map(potReading, 0, 4095, 0, 255);


  if( state == 0  )
  {
    // turn the LED off
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
  }
  else if(state > 0 && state < 85) //red
  {
    digitalWrite( redPin, LOW );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
  }
  else if(state > 85 && state < 170) //green
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, LOW );
    digitalWrite( bluePin, HIGH );
  }
  else if(state > 170 && state < 255) //blue
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, LOW );
  }

  buttonpublish(state);

  delay (100);

}

  //press button to publish
  void buttonpublish(int value)
  {
   int buttonState = digitalRead( buttonPin );

   if( buttonState == LOW )
   {
     delay(2000);
     if( buttonState == LOW)
     {
       if(value > 0 && value < 85)
       {
         publishred();
         blinkredLED();
       }
       else if(value > 85 && value < 170)
       {
         publishgreen();
         blinkgreenLED();
       }
       else if(value > 170 && value < 255)
       {
         publishblue();
         blinkblueLED();
       }
     }
   }
   delay(100);
  }

  //publish red
  void publishred()
  {
    Spark.publish( "db2015/conchain123/color2", "RED" );
  }

  //publish green
  void publishgreen()
  {
    Spark.publish( "db2015/conchain123/color2", "GREEN" );

    //Spark.publish( "db2015/conchain123/green" );
  }

  //publish blue
  void publishblue()
  {
    Spark.publish( "db2015/conchain123/color2", "BLUE" );

    //Spark.publish( "db2015/conchain123/blue" );
  }

  void blinkredLED()
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
    for( int i = 0 ; i < 3 ; i++ )
    {
    digitalWrite( redPin, LOW );

    delay( 500 );

    digitalWrite( redPin, HIGH );

    delay( 500 );
    }
  }
  
  void blinkgreenLED()
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
    for( int i = 0 ; i < 3 ; i++ )
    {
    digitalWrite( greenPin, LOW );

    delay( 500 );

    digitalWrite( greenPin, HIGH );

    delay( 500 );
    }
  }

  void blinkblueLED()
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
  for( int i = 0 ; i < 3 ; i++ )
  {
  digitalWrite( bluePin, LOW );

  delay( 500 );

  digitalWrite( bluePin, HIGH );

  delay( 500 );
}
  }

  void receiveColor( const char *event, const char *data)
  {

    if( strcmp( data, "RED" ) == 0 ){
      receiveRED( event, data);
    }

   else if( strcmp( data, "GREEN" ) == 0 ){
      receiveGREEN( event, data);
    }


   else if( strcmp( data, "BLUE" ) == 0 ){
      receiveBLUE( event, data);
    }

  else
  {
    blinkblueLED();
    }


  }


  void receiveRED(const char *event, const char *data)
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
    blinkredLED();
    digitalWrite( redPin, LOW );
    delay(3000);
  }

  void receiveGREEN(const char *event, const char *data)
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
    blinkgreenLED();
    digitalWrite( greenPin, LOW );
    delay(3000);
  }

  void receiveBLUE(const char *event, const char *data)
  {
    digitalWrite( redPin, HIGH );
    digitalWrite( greenPin, HIGH );
    digitalWrite( bluePin, HIGH );
    blinkblueLED();
    digitalWrite( bluePin, LOW );
    delay(3000);
  }
Click to Expand
0
x