Just Breathe

Made by mdworman, Billy Lawton and Karan Naik

Found in DioT 2019: Social Objects - Part 2 · UNLISTED (SHOWN IN POOLS)

Many people have a desire to stay connected to their family and loved ones but don’t necessarily have the time or opportunity to do so, either because of work or distance constraints. Our product provides a simple button interface that communicates feelings/emotions via color (yellow – Love; red – I’m stressed; blue – calm down). This solution allows loved ones to quickly communicate with each other and provide peace of mind and comfort quickly through a simple button press on the wrist.

0
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

#include <math.h>

int button = D3; //button is read from D3
int ledpin = D4; //LED output is D4

unsigned long now = 0; //variable to keep track of time
unsigned long pressed = 0; //variable to keep track of time for buttonState
unsigned long eventTimer = 0; //variable to keep track of time for events

int buttonState = 0; //variable to keep track of button presses
long lastPublishedAt = 0; // This value will store the last time we published an event
int publishAfter = 1000; // this is the time delay before we should publish a new event
int eventState = 0; //variable to keep track of incoming events
int red = 0;//initializes red to 0
int green = 0;//initializes green to 0
int blue = 0;//initializes blue to 0


#define PIXEL_PIN D2
#define PIXEL_COUNT 7
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);


void setup()
{
    Particle.subscribe(  "diot/2019/paired/LOVE" , getLove ); //subscription to shared events
    Particle.subscribe(  "diot/2019/paired/SOS" , getHelp );
    Particle.subscribe(  "diot/2019/paired/BREATHE" , justBreathe );
    pinMode(button, INPUT_PULLUP);
    pinMode(ledpin, OUTPUT);
    strip.begin();
    strip.show(); // Initialize all pixels to 'off'
}

void loop()
{
    int buttonRead = digitalRead (button); 
    delay(10);
    if (buttonRead == LOW) //looking for button press
    {
        pressed = millis(); //remembers when the button was pressed    
        light(); //LED confirms button pressed
//        lightColor();
//        confirm();
        buttonState++; //Advances the button state for double or tripple press
        delay(10);
    }
    
    now = millis(); //to compare current time to last time button pressed
    
    if (eventState==1) { breatheYellow(); }
    if (eventState==2) { breatheRed(); }
    if (eventState==3) { breatheBlue(); }
    if (buttonState==2) { light2(); }
    if (buttonState==3) { light3(); }
    if (buttonState>=3) { buttonState=3; }
    if (now-pressed>=2000) { buttonState=0; digitalWrite (ledpin, LOW);} //resets the button state if >2 seconds have elapsed
    if (eventState==1 || eventState==2 || eventState==3){eventTimer=millis(); }
//    if (now-eventTimer>=60000) {eventState=0; }//this line prevents everything from working
}   


// void lightColor()
// {
//     if (buttonState <= 2000){red=255; green=255; blue=0;}
//     if (buttonState <= 2000 && buttonState <= 4000){red=255; green=255; blue=0;}
//     else {red=255; green=255; blue=0;}
//}



// float confirm()
// {
//     uint32_t c = strip.Color(red, green, blue);
//     int i=0;
//     for(i=0; i< strip.numPixels(); i++) 
//     {
//         strip.setPixelColor(i, c );
//     }
//     strip.show();
    
// }

void light()//causes LED to blink once to confirm loveSent
{
    sendLove();
    digitalWrite (ledpin, HIGH);
    delay(100);
    digitalWrite (ledpin, LOW);
    delay(100);

}

void light2()//causes LED to blink rapidly to confirm SOSsent
{
    sendSOS();
    digitalWrite (ledpin, HIGH);
    delay(100);
    digitalWrite (ledpin, LOW);
    delay(100);

}

void light3()//causes the led to blink more rapidly to confirm justBreathe has been sent
{
    sendBreathe();
    digitalWrite (ledpin, HIGH);
    delay(50);
    digitalWrite (ledpin, LOW);
    delay(50);
}

void sendLove(){ //sends shared event 1
  if( lastPublishedAt + publishAfter < millis() )
  {  // check that it's been 10 secondds since our last publish
      String eventName = "diot/2019/paired/LOVE" + System.deviceID();
      Particle.publish( eventName, "love sent" );
      lastPublishedAt = millis();
  }
}

void sendSOS(){ //sends shared event 2
  if( lastPublishedAt + publishAfter < millis() )
  {  // check that it's been 10 secondds since our last publish
      String eventName = "diot/2019/paired/SOS" + System.deviceID();
      Particle.publish( eventName, "SOS sent" );
      lastPublishedAt = millis();
  }
}

void sendBreathe(){ //sends shared event 2
  if( lastPublishedAt + publishAfter < millis() )
  {  // check that it's been 10 secondds since our last publish
      String eventName = "diot/2019/paired/BREATHE" + System.deviceID();
      Particle.publish( eventName, "Just Breathe" );
      lastPublishedAt = millis();
  }
}

void getLove(const char *event, const char *data) //receives shared event 1
{
    String eventName = String( event ); // convert to a string object
    String deviceID = System.deviceID();    // device id = 0123456789abcdef
    event = "diot/2019/paired/LOVE";

    if( eventName.indexOf( deviceID ) != -1 )
    {
      // if we get anything other than -1
      // the event came from this device.
      // so stop doing stuff
    return;
    }
    eventState=1;
}  

void getHelp(const char *event, const char *data) //receives shared event 2
{
    String eventName = String( event ); // convert to a string object
    String deviceID = System.deviceID();    // device id = 0123456789abcdef
    event = "diot/2019/paired/SOS";//

    if( eventName.indexOf( deviceID ) != -1 )
    {
       //if we get anything other than -1
       //the event came from this device.
       //so stop doing stuff
    return;
    }
    eventState=2;
} 

void justBreathe(const char *event, const char *data) //receives shared event 3
{
    String eventName = String( event ); // convert to a string object
    String deviceID = System.deviceID();    // device id = 0123456789abcdef
    event = "diot/2019/paired/SOS";//

    if( eventName.indexOf( deviceID ) != -1 )
    {
       //if we get anything other than -1
       //the event came from this device.
       //so stop doing stuff
    return;
    }
    eventState=3;
}  

float breatheRed()
{
    float val = (exp(sin(millis()/2000.0*M_PI)) - 0.36787944)*108.0;
    Serial.println( val );
    uint16_t i;
    uint32_t c = strip.Color(val, 0, 0);
    for(i=0; i< strip.numPixels(); i++)
        {
        strip.setPixelColor(i, c );
        }
    strip.show();
}

float breatheYellow()
{
    float val = (exp(sin(millis()/2000.0*M_PI)) - 0.36787944)*108.0;
    Serial.println( val );
    uint16_t i;
    uint32_t c = strip.Color(val, val, 0);
    for(i=0; i< strip.numPixels(); i++) 
    {
        strip.setPixelColor(i, c );
    }
    strip.show();
}

float breatheBlue()
{
    float val = (exp(sin(millis()/2000.0*M_PI)) - 0.36787944)*108.0;
    Serial.println( val );
    uint16_t i;
    uint32_t c = strip.Color(0, 0, val );
    for(i=0; i< strip.numPixels(); i++) 
    {
        strip.setPixelColor(i, c );
    }
    strip.show();
}
Click to Expand
0

Problem Overview: Clearly explain and provide a succinct overview of the problem and how the proposed product solves that problem

Many people have a desire to stay connected to their family and loved ones but don’t necessarily have the time or opportunity to do so, either because of work or distance constraints. Our product provides a simple button interface that communicates feelings/emotions via color (yellow – Love, I’m thinking about you; red – I’m stressed; blue – Don’t worry, calm down and breathe). This solution allows loved ones to quickly communicate with each other and provide peace of mind and comfort quickly and efficiently through a simple button press on the wrist.

Design Process: Briefly describe the design process (iterations, refinements, challenges encountered)

As we constructed the code for our project, we encountered issues related to communicating the signals between the two devices. Each particle device could send a stress or love signal that would register in the cloud but neither could receive the distress signal. We also experienced some hiccups related to getting the blue light to breathe to intuitively communicate to the other person to calm down and breathe. There was some time lag in running the code between the devices that prevented them from showing the blinking/breathing LED light colors at the same time. Because we have 3 different shared events, we learned how to deal with sending and receiving multiple shared events. Selecting the event to send we’re using a single double or triple button press to communicate each state. We’re experimenting with ways to make this easier and more intuitive.

Outcome: Document the outcome itself (code, circuit diagrams, photos, design files, 3d models, video demonstrations, etc. as required) and provide a short narrative. A bill of materials (sensors, input devices, actuators, and other components) should be provided. This documentation should be sufficiently rich to allow anyone to repeat / recreate it.

Materials: 2 neopixel strips, two LEDs, jumper wires, 2 actuators

In this example, it shows that someone can communicate that they’re thinking about someone with a breathing yellow light. The other person will get a sense of happiness and gratification from this quick notification that appears on their wrist. They can quickly communicate the same emotions back or a red distress signal for when they’re feeling down or sad. The first person can then respond with a breathing blue light to denote that they are there for them to help them relax, calm down, and breathe. This emotional comfort provides significant daily benefits for people who don’t have the time to call or can’t be present due to distance. The code accomplishes this through a certain number of button presses, which each communicate a different color and corresponding emotion from person to person through the particle cloud. 

0
https://vimeo.com/317592710
x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

49713 Designing for the Internet of Things

· 18 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


Focused on
About

Many people have a desire to stay connected to their family and loved ones but don’t necessarily have the time or opportunity to do so, either because of work or distance constraints. Our product provides a simple button interface that communicates feelings/emotions via color (yellow – Love; red – I’m stressed; blue – calm down). This solution allows loved ones to quickly communicate with each other and provide peace of mind and comfort quickly through a simple button press on the wrist.

Created

February 15th, 2019