Introduction: Emotidora: Hats With Emotions

This project, Emotidora, will help a user express his/her emotions about events in day-to-day life. Weve all been in
situations where something very exciting or unfortunate has happened to us and we want to share it with other people. This
usually involves the expression of some emotion through visual cues, and when prompted by a peer, it can lead to expressing
the situation/emotion. Emotidora enables people to wear their emotions on their head. It allows people to share how they will
know how they feel and it can lead to more natural self-expression and conversation. Additionally, the person can change
their hats emotion at any time and can also transfer the emotion to another (feeling happy, but your friend is feeling sad?
transfer your emotion!).

Ideally, the hat will do the following:
1) When a person feels a certain way, he/she can display a corresponding emoticon on the hat by using a variable resistor,
a potentiometer, to switch the emotion on the hat given six options: ecstatic, happy, straight-face, sad, anger, and surprise.
2) Interaction with another person that is wearing a hat is possible if they come close enough that an infrared communication
is made between the hats (i.e., they will know that they are in proximity and will allow more interaction to take place).
a) Another user patting your hat’s roof in a caring way would be able to change the emotion on your hat by stepping
it up a level. Say you were feeling ’straight-faced’ and much of anything at the moment. A tap on the hat by
another Emotidora user will now more your emotion from ’straight-face’ to ’happy’ because you’ve been cared for.
b) The other interaction that is possible is through a hug, another caring gesture. Hall-Effect sensors (that detect
magnetic fields) are placed on opposite sides of each hat. Magnets are on either side of the sensor. When both
people hug and the hall-effect sensor on each comes in contact with the magnets on the other hat, your current
emoticon gets happier as well.

Step 1: What You Will Need

-2 Arduinos
-2 photoresistor sensors
-2 1K ohm resistors
-2 Hall effect sensors
-4 magnets
-2 100 ohm resistors
-10 330 ohm resistors
-66 LEDs (27 of one color, 6 of another)x2
-solder
-soldering iron
-electrical wire
-electrical tape
-solderless proto-board
-scissors
-5V (up to 9V) battery

Step 2: Constructing: the Emoticon Face

The first step to Emotidora is to create the emoticon face that will be displayed on the front face of the hat. The face can
be in any design you want, but ideally it should be able to incorporate all of the combinations of smiley faces that you want
in the hat.
The faces that we wanted to show are 6: ecstatic, happy, straight, sad, anger, suprise.
The figure 1 shows the way that we built our emoticon face and every face that is displayed on it.


Take your 33 LEDs and your 5 330 Ohm resistors. And hook up all of the LEDs in parallel for each row of the smiley,
with the longer lead of each LED in line with the 330Ohm resistor as it connects to +5V, which in our case is output by the
pins of an arduino. Do as shown Figure 2, on a breadboard. Remember that the LED is a diode, and the longer end of the
LED should be connected to the resistor. This resistor is connected to our arduino pins (2-6) which output a 5V signal when
they are turned on. The shorter end of the LED must be connected to ground.

Now in order to switch between the smileys, we need to program the arduino to be able to take each different face as a
’FaceCase’, where it will turn on the row of LEDs based on which FaceCase that it is given. To do this, we can write a ’switch
case’ program in C for the arduino, with each case (each smiley) telling the arduino which pins to turn on (which LEDs to
light up). The table below shows which pins should be turned on for each smiley face.

Face
Ecstatic--Pins: 3,4,5
Happy--Pins: 2,5
Straight--Pins: 3,5
Sad--Pins: 4,5
Angry--Pins: 3,4,5,6
Surprised--Pins: 2,4,5

Every time the smiley face is switch, the FaceCase variable in the arduino code switches, changing which pins are on (i.e.,
which smiley is displayed).
Now to have the user be able to control the smiley that is displayed on the hat, we are going to use a potentiometer (which
is a adjustable resistor) to ’sweep’ through all of the smiley faces. Given the resistor in the potentiometer can vary over 255
values, based on what range of values the potentiometer currently is, the smiley will change. This 0-255 reading of the resistor
goes into Pin A0 (analog pin, which will get converted into the 0-255 number) on the Arduino. We have expanded the range
artificially so that the arduino maps the 0-255 value instead from 0-600 (to give more range and less room for error). The
arduino code for all of the different sensors and interaction will be found in the appendix (at the bottom) of this HowTo
manual.
When the potentiometer is between:
0-99: face = Ecstatic
101-199: face = Happy
201-299: face = Straight
301-399: face = Sad
401-499: face = Angry
501-599: face = Surprised
In terms of user interaction, as you can see in figure ??, the hat bearer can turn the potentiometer around its whole span starting
at one end, and can have every face displayed. When the user feels a different emotion, they can turn the potentiometer again
and mirror how they feel. This is the first step to completing Emotidora!

Step 3: Constructing: the Light-Sensing Circuit

The light-sensing circuit will help in making one person’s Emotidora make another person feel better. A pat on the head
will mean that a photoresistor that is hiding there (a photoresistor changes its resistance based on how much light is present)
will either be covered (darkness) or will have light falling on it. This change in voltage across the resistor will mean that we
can use this difference to help the patter change the friend’s emotion to become happier by one increase in smiley (so from
happy to ecstatic, straight to happy, sad to straight, angry to straight. Surprise does not fit in, and thus is not affected).
The circuit for the photoresistor is shown in the figure below, where it is tied to power (Vcc) and another resistor, a 1Kohm resistor
is tied to ground. The voltage is taken in between both, creating a voltage divider. The ratio of voltage that comes out, is
V out = [photoresistor/(photoresistor+1Kohm)]*V in. So based on how the photoresistor is covered and its resistance changes, Vout respectively changes.

This Vout is what connected to the arduino, at analog pin A1. Once again, we take in an analog voltage value here and map
it to a digital range of values between 0-255. If the light level difference is greater that 70 (the person’s hat is being patted),
then we upgrade by a smiley face. Otherwise, nothing happens. Once again, the C code for this is reflected at the end of this
document.

Step 4: Constructing: the Magnetic-Sensing Circuit


The magnetic field-sensing circuit will also help one person’s Emotidora make another person feel better. A hug between
the two people wearing the hats will set off a hall-effect sensor on the rim of the first hat when magnets from the other hat
come close to it. The hall-effect can sense a magnetic field in its vicinity. This change in voltage shows is used to upgrade
the smiley face (as like in the photoresistor case).

The circuit for the hall effect sensor is shown in figure 2 below. Make sure to look at the orientation of your hall effect sensor to
figure out the three pins on it. It is pin 3, Vout, that goes to analog A5 on the arduino. The analog voltage value here is
mapped to a digital range of values. When there is a magnetic field presence in the vicinity of the hall effect, the analog read
goes very close to 0. Thus, the C code on the arduino says that if the hall effect value that is read is less than 5 (close to 0),
then upgrade by a smiley face. Otherwise if there is no hugging between the two hats, nothing happens. Once again, the C
code for this is reflected at the end of this document.  And Figure 1 below shows how the hall-effect sensor and the two magnets look on the hat.


Step 5: Putting It All Together


Now that we have every individual circuit functioning (hopefully), we want to integrate the system together. The best way
to keep your circuits secure is to solder them permanently onto a solderless protoboard. Solder all of the smiley LEDs onto
a small protoboard so it can stick onto the front of the hat. Then use another protoboard will do well to hold the hall-effect
circuit, the photoresistor circuit, and the potentiometer circuit. Remember to make sure that each of these sensors have some
long wire coming off them though, because they need to be placed strategically around the hat.
The hall effect must go on a side brim (and on the opposite side for the other hat that you are building), the light sensor needs
to stick out from the top of the hat, and then potentiometer on the side as well where the hat-bearer can access it.
Also make sure to hook up each part of the circuit to the corresponding arduino pin that it should be connected to, as seen in
figure 1. The figure 2 shows how the writing inside the
hat looks. All of it is later on covered by a large piece of felt to hide these electronics and make the hat-bearer’s experience
safer.  The figure 3 shows the positioning of each of the sensors on the hat.

Now all you have to do is load the arduino code that we have given you below, onto the arduino and you are good to go! Try
out your hats with a friend, and see if you can make each other happier! =) Enjoy.

Step 6: Arduino Code (how We Did It)

//counter
int counter = 0; //not using this right now-tried to implement for when hall effect sensor wasn't working properly; i.e. its reading was fluctuating wildly.

//Photoresistor
int lightPin = A1; //assign light sensor input pin

//int groundPin = A4;
//int groundValue = 0;

//Hall Effect Sensor
int hallPin = A5; //assign hall effect sensor input pin
int hallValue = 0;

//instantiating potentiometer
int sensorPin = A0; // assign the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int outputValue = 0;
int newSensorValue = 0;
int newOutputValue = 0;
//int newerOutputValue = 0;

//assign pins to LED face components
int smile = 2;
int straightface = 3;
int sad = 4;
int eyes = 5;
int brows = 6;

//switch case variable
int face = 1;

//emotions
const int ECSTATIC = 1;
const int HAPPY =2;
const int STRAIGHT =3;
const int SAD = 4;const int ANGRY =5;
const int SURPRISE = 6;

//SETUP
void setup() {
Serial.begin(9600);
//Hall Effect Sensor
pinMode(hallPin, INPUT);
//Potentiometer
pinMode(smile,OUTPUT);
pinMode(straightface,OUTPUT);
pinMode(sad,OUTPUT);
pinMode(eyes,OUTPUT);
pinMode(brows,OUTPUT);
}
//FACE SWITCHING FUNCTION
void faceswitch() {
switch(face){
//ecstatic
case 1: digitalWrite(eyes, HIGH);
digitalWrite(smile, HIGH);
digitalWrite(straightface, HIGH);
digitalWrite(sad, LOW);
digitalWrite(brows, LOW);
break;
//happy
case 2: digitalWrite(eyes, HIGH);
digitalWrite(smile, HIGH);
digitalWrite(straightface, LOW);
digitalWrite(sad, LOW);
digitalWrite(brows, LOW);
break;
//straight
case 3: digitalWrite(eyes, HIGH);
digitalWrite(smile, LOW);
digitalWrite(sad, LOW);
digitalWrite(straightface, HIGH);
digitalWrite(brows, LOW);
break;
//sad
case 4: digitalWrite(eyes, HIGH);
digitalWrite(smile, LOW);
digitalWrite(sad, HIGH);
digitalWrite(straightface, LOW);
digitalWrite(brows, LOW);
break;
//angry
case 5: digitalWrite(eyes, HIGH);
digitalWrite(smile, LOW);
digitalWrite(sad, HIGH);
digitalWrite(straightface, HIGH);
digitalWrite(brows, HIGH);
break;
//surprise
case 6: digitalWrite(eyes, HIGH);
digitalWrite(smile, HIGH);
digitalWrite(sad, HIGH);
digitalWrite(straightface, LOW);
digitalWrite(brows, LOW);
break;
}
}

//IF STATEMENTS IN RUNNING LOOP
void loop() {

//Photoresistor
int lightLevel = analogRead(lightPin); //Read the
// lightlevel
lightLevel = map(lightLevel, 0, 900, 0, 255);

lightLevel = constrain(lightLevel, 0, 255);//make sure the
//value is between //0 and 255

Serial.println(lightLevel);
//delay(50);



hallValue = analogRead(hallPin);
Serial.println(hallValue);
delay(50);

//potentiometer
sensorValue = analogRead(sensorPin); // read the value from the sensor:
outputValue = map(sensorValue, 0, 1023, 0, 600);

delay(50);

faceswitch();

if(outputValue<100){
face = 1; //ecstatic
}

else if(outputValue>100 && outputValue<200){
face = 2; //happy
}

else if(outputValue>200 && outputValue<300){
face = 3; //straight
}

else if(outputValue>300 && outputValue<400){
face = 4; //sad
}

else if(outputValue>400 && outputValue<500){
face = 5; //angry
}

else if(outputValue>500 && outputValue<600){
face = 6; //surprise
}



if (lightLevel>70
){

newOutputValue = map(analogRead(sensorPin), 0, 1023, 0, 600); // read the value from the sensor:
newOutputValue = constrain(newOutputValue, 0, 600);

while((abs(map(analogRead(sensorPin), 0, 1023, 0, 600) - newOutputValue)) < 50){


if (face != 5 && face != 6 && face != 1) {
face -= 1;
faceswitch();
while((abs(map(analogRead(sensorPin), 0, 1023, 0, 600) - newOutputValue)) < 50){
delay(1000);
}
//Serial.println("face change");
}

if (face == 5) {
face -= 2;
faceswitch();
while((abs(map(analogRead(sensorPin), 0, 1023, 0, 600) - newOutputValue)) < 50){
delay(1000);
}
//Serial.println("change from angry");
}
}
}



if (hallValue < 5) {



newOutputValue = map(analogRead(sensorPin), 0, 1023, 0, 600); // read the value from the sensor:
newOutputValue = constrain(newOutputValue, 0, 600);

while((abs(map(analogRead(sensorPin), 0, 1023, 0, 600) - newOutputValue)) < 50){


if (face != 5 && face != 6 && face != 1) {
face -= 1;
faceswitch();
while((abs(map(analogRead(sensorPin), 0, 1023, 0, 600) - newOutputValue)) < 50){
delay(1000);
}
Serial.println("face change");
}

if (face == 5) {
Serial.println("change from angry");
face -= 2;
faceswitch();
while((abs(map(analogRead(sensorPin), 0, 1023, 0, 600) - newOutputValue)) < 50){
delay(1000);
}

}

}
}

}



Comments

About This Instructable

2,331views

3favorites

License:

More by aiswaryak:Making Indian Masala noodlesEmotidora: Hats with EmotionsA Belly Dancer Bonanza
Add instructable to: