Isaac WolfDenis BesicJake Mitchell
Published © GPL3+

Lane of Things - Emotion Collection

We created a box with buttons that represent a positive or negative emotion. Through these buttons we were able to see what emotion was felt

BeginnerShowcase (no instructions)2 hours507
Lane of Things - Emotion Collection

Things used in this project

Hardware components

Concave Button
One button is red while another button is green.
×2
LED - RGB Clear Common Cathode
×2
Photon
Particle Photon
×1
Resistor 100 ohm
Resistor 100 ohm
×2

Story

Read more

Schematics

Emotion Collection

Fritzing Diagram

SVG

The svg file for the box.

Prototype

Early Concept

Sketch

Code

Emotion Collection

Arduino
It checks whenever a green or red button is pressed and it stores it in variables. These variables are then logged into google sheets.
// *** variables for our LEDs
int redPin = A4; 
int greenPin = A3;
   
int redValue = 255; 
int greenValue = 255;

// *** variables for buttons
const int posButton = 0;
const int negButton = 1;

// *** the variables to calculate happiness
  bool ovEmotion; // if true, people are more happy. If false, people are more sad
  int amtPressed; // how many times any button was pressed
  int happyPressed; // amount happy button was pressed
  int sadPressed; // amount sad button was pressed
  double ovHappy; // a number less than one, % of how many people are happy
  double ovSad; // a number less than one, % of how many people are sad

void setup() 
{
    // *** Set up for the LEDs
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    
    // this could be the command to turn off the LEDs. Test later
    analogWrite(redPin, redValue);
    analogWrite(greenPin, greenValue);
    
    // *** set up for the buttons
    Serial.begin(9600);
    pinMode(posButton,INPUT_PULLDOWN);
    pinMode(negButton,INPUT_PULLDOWN);
    
    Particle.variable("ovEmotion", ovEmotion);
    Particle.variable("amtPressed", amtPressed);
    Particle.variable("happyPressed", happyPressed);
    Particle.variable("sadPressed", sadPressed);
    Particle.variable("ovHappy", ovHappy);
    Particle.variable("ovSad", ovSad);
}

void loop() 
{
    
    
    // *** when green button is pressed
    if(digitalRead(posButton) == HIGH)
    { 
        // emotion being calculated
        amtPressed++;
        happyPressed++;
        ovHappy = (double) happyPressed / amtPressed;
        ovSad = (double) sadPressed / amtPressed;
        ovEmotion = ovHappy > ovSad;
        
        // blink the lights rapidly
        for(int i = 15; i > 0; i--)
        {
        digitalWrite(redPin, LOW);
        digitalWrite(greenPin, LOW);
        delay(70);
        digitalWrite(redPin, HIGH);
        digitalWrite(greenPin, HIGH);
        delay(70);
        }
        // turn on the red or green light depending on ovEmotion
        delay(300);
        
        
        Serial.println("Button Pressed: Green");
        Serial.println("ovEmotion: " + String(ovEmotion));
        Serial.println("amtPressed: " + String(amtPressed));
        Serial.println("happyPressed: " + String(happyPressed));
        Serial.println("sadPressed: " + String(sadPressed));
        Serial.println("ovHappy: " + String(ovHappy));
        Serial.println("ovSad: " + String(ovSad));
        Serial.println("***************");
    }
    // *** when red button is pressed
    if(digitalRead(negButton) == HIGH)
    {
        // emotion being calculated
        amtPressed++;
        sadPressed++;
        ovHappy = (double) happyPressed / amtPressed;
        ovSad = (double) sadPressed / amtPressed;
        ovEmotion = ovHappy > ovSad;
        
       // blink the lights rapidly
        for(int i = 15; i > 0; i--)
        {
        digitalWrite(redPin, LOW);
        digitalWrite(greenPin, LOW);
        delay(70);
        digitalWrite(redPin, HIGH);
        digitalWrite(greenPin, HIGH);
        delay(70);
        }
        // turn on the red or green light depending on ovEmotion
        delay(300);
        
        
        
        Serial.println("Button Pressed: Red");
        Serial.println("ovEmotion: " + String(ovEmotion));
        Serial.println("amtPressed: " + String(amtPressed));
        Serial.println("happyPressed: " + String(happyPressed));
        Serial.println("sadPressed: " + String(sadPressed));
        Serial.println("ovHappy: " + String(ovHappy));
        Serial.println("ovSad: " + String(ovSad));
        Serial.println("***************");
        
        
    }
    
    if(!ovEmotion)
    {
        digitalWrite(greenPin, HIGH);
        digitalWrite(redPin, LOW);
    }
    else 
    {
        digitalWrite(redPin, HIGH);
        digitalWrite(greenPin, LOW);
    }
    
    /*
      IMPORTANT
      Figure out where to send our data at the end of the day
    */
    
}

Credits

Isaac Wolf

Isaac Wolf

1 project • 1 follower
Denis Besic

Denis Besic

-1 projects • 0 followers
Jake Mitchell

Jake Mitchell

-1 projects • 0 followers
I'm from Greg

Comments