James Chen’s Final – Emotion Cloud

For the Final, I work in groups with Alice, Hoiyan and Sarabi. We made a wearable emotion cloud which can help us express emotions on our head.

When we start to brain storm about the project, we want to do something with our emotions. We want to detect our emotion and express it out. My first idea is to use sensors like heart rate sensor and breathe sensor to get the data of the user and get the emotion by analyzing the data. For example, when someone’s hear rate increases rapidly, it means he is not in good mood. He is either angry or nervous. But when one’s heart rate is stable and low, we can say he is calm and pleasure. But several hours later I realize that the link between the heart rate, breathe rate and the emotion is not that tight. It’s not that persuasive to tell one’s emotion by just looking at such limited data.

So we start to think what else can we use to get the data about the emotion. We ask Marcele and she suggested us to use buttons, The user can choose the emotion to express it out. It sounds great as it’s easy to do and we the data should be accurate. But I then start to think about our target audience. If we want to help those who are shy to say it out or to express their emotions on their face, they will never press the button under any emotion. What we need is some method which can detect the emotion silently without being noticed.

Then we come up with the idea of using gestures. When we are happy, we sometimes will turn up the thumb. When we are angry, we will clench our fists and when we are sad, we will use our hand to touch our elbows. It’s not because we do this intentionally, it’s more like a muscle memory. When we are in that mood, our body will make the gesture itself.

So I add conductive fabrics to the palm which connect to the 5V, three piece of fabrics connects to the thumb, the ring finger and the elbow. On the other hand, they are connected with digital pins and ground. So when we put our thumb up, one circuit will be complete. When we clench our fists, two circuit will be complete. When we touch our elbow, the other circuit will be complete. So whichever gesture we make, the Arduino will receive the signal and figure it out.

On the other side, we use a cloud with LEDs hidden inside to express the emotion. When it receive the signal of the happy emotion, it will light up the white LED and a sun will pop up be the movement of the servo. When it receive the signal of angry, it will light up the LED randomly to simulate the lightening. And when it receive the signal of sad, it will light up the cloud with a blue LED.

Here is our code for the sender:

int Out1Pin = 6;
int Out2Pin = 7;

int button1Pin = 9; //ring finger
int button2Pin = 10; //thumb
int button3Pin = 11; //palm

void setup() {
// put your setup code here, to run once:
pinMode(Out1Pin, OUTPUT);
pinMode(Out2Pin, OUTPUT);

pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);

Serial.begin(9600);
}

void loop() {
Serial.print(“1: “);
Serial.print(digitalRead(button1Pin));
Serial.print(” “);

Serial.print(“2: “);
Serial.print(digitalRead(button2Pin));
Serial.print(” “);

Serial.print(“3: “);
Serial.print(digitalRead(button3Pin));
Serial.print(” “);

Serial.println();
// put your main code here, to run repeatedly:
if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == HIGH && digitalRead(button3Pin) == LOW) {
digitalWrite(Out1Pin, HIGH);
digitalWrite(Out2Pin, LOW);
Serial.println(“angry”);
delay(500);
} else if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == LOW && digitalRead(button3Pin) == LOW) {
digitalWrite(Out1Pin, LOW);
digitalWrite(Out2Pin, HIGH);
Serial.println(“happy”);
delay(500);
} else if (digitalRead(button1Pin) == LOW && digitalRead(button2Pin) == LOW && digitalRead(button3Pin) == HIGH) {
digitalWrite(Out1Pin, HIGH);
digitalWrite(Out2Pin, HIGH);
Serial.println(“sad”);
delay(500);
}

if (digitalRead(button1Pin) == LOW && digitalRead(button2Pin) == LOW && digitalRead(button3Pin) == LOW) {
digitalWrite(Out1Pin, LOW);
digitalWrite(Out2Pin, LOW);
Serial.println(“default”);
delay(500);
} else if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == HIGH && digitalRead(button3Pin) == HIGH) {
digitalWrite(Out1Pin, LOW);
digitalWrite(Out2Pin, LOW);
Serial.println(“default”);
delay(500);
}
}

Here is the code for our receiver:

#include <Servo.h>

Servo myservo;

int incomingByte;

int servoPos = 0;
int myPos = 0;

int WhiteLEDPin = 9;
int YellowLEDPin = 11;
int BlueLEDPin = 10;

int In1Pin = 6;
int In2Pin = 7;

int input1;
int input2;
int lighteningCounter = 0;
int LEDState = 0;

bool happy = false;
bool sad = false;
bool angry = false;

float timer;

void setup() {
// put your setup code here, to run once:
pinMode(WhiteLEDPin, OUTPUT);
pinMode(YellowLEDPin, OUTPUT);
pinMode(BlueLEDPin, OUTPUT);

pinMode(In1Pin, INPUT);
pinMode(In2Pin, INPUT);

myservo.attach(12);

Serial.begin(9600);

timer = millis();
}

void loop() {
// put your main code here, to run repeatedly:
input1 = digitalRead(In1Pin);
input2 = digitalRead(In2Pin);

// if (Serial.available() > 0) {
// incomingByte = Serial.read();
// if (incomingByte == ‘1’) { //Happy Emotion
// sad = false;
// angry = false;
// happy = true;
// } else if (incomingByte == ‘2’) { //Sad Emotion
// happy = false;
// angry = false;
// sad = true;
// } else if (incomingByte == ‘3’) { //Sad Emotion
// happy = false;
// sad = false;
// angry = true;
// }
// }

if (input1 == HIGH && input2 == LOW) { //Happy Emotion
sad = false;
angry = false;
happy = true;
timer = millis();
Serial.println(“happy”);
} else if (input1 == HIGH && input2 == HIGH) { //Sad Emotion
happy = false;
angry = false;
sad = true;
timer = millis();
Serial.println(“sad”);
} else if (input1 == LOW && input2 == HIGH) { //angry Emotion
happy = false;
sad = false;
angry = true;
timer = millis();
Serial.println(“angry”);
}

// counter reset
if (millis() – timer > 5000) {
happy = false;
sad = false;
angry = false;
Serial.println(“deflaut”);
}

if (happy == true) {
//Serial.println(“happy”);
digitalWrite(BlueLEDPin, LOW);
digitalWrite(WhiteLEDPin, HIGH);
digitalWrite(YellowLEDPin, HIGH);
if (myPos != 1) {
myPos –;
myservo.write(myPos);
delay(15);
}
}
if (sad == true) {
//Serial.println(“sad”);
digitalWrite(BlueLEDPin, HIGH);
digitalWrite(WhiteLEDPin, LOW);
digitalWrite(YellowLEDPin, LOW);
if (myPos != 120) {
myPos ++;
myservo.write(myPos);
delay(15);
}
}
if (angry == true) {
//Serial.println(“angry”);
digitalWrite(YellowLEDPin, LOW);
digitalWrite(BlueLEDPin, LOW);
if (myPos != 120) {
myPos ++;
myservo.write(myPos);
delay(15);
}
if (lighteningCounter <= 12) {
int abc = random(0, 10);
if (abc <= 4) {
digitalWrite(WhiteLEDPin, HIGH);
delay(50);
Serial.println(abc);
} else {
digitalWrite(WhiteLEDPin, LOW);
delay(50);
Serial.println(abc);

}
} else {
digitalWrite(WhiteLEDPin, LOW);
}
if (lighteningCounter >= 14) {
lighteningCounter = 0;
}
lighteningCounter++;
}
if (happy == false && sad == false && angry == false) {
digitalWrite(BlueLEDPin, LOW);
digitalWrite(WhiteLEDPin, LOW);
digitalWrite(YellowLEDPin, LOW);
if (myPos != 120) {
myPos ++;
myservo.write(myPos);
delay(15);
}
}
}

 

Here are a short video about our project:

James Chen’s Buzzer Project – Music Oversleeve

For the buzzer project, I work with Alice Guo and make two fabric buttons on the oversleeve to play the the music and stop playing it.

Our basic concept is when the I press the start button, two pieces of separate conductive fabrics will connect with each other. The sender Arduino will receive the signal and will send a signal to the receiver Arduino board to let it start playing the music with the buzzer. When the other button is pressed, another signal will be sent to the receiver board and the music will be stopped.

The most difficult part in this project is to let the buzzer play music. To reach that goal, I use the library called ‘tune’. Basically it allow us to control the frequency of the sound played by the buzzer. The library also allow us to track the duration of each sound played by the buzzer. With the library and the correct setting, we can play the entire song with the buzzer.

But in the sample code of the library, it use the for loop to play the sound one by one. Which means once I enter the for loop, I cannot stop playing it until the whole song is finished. So I change the for loop into an if statement with a couter++ in it. With such update, I can stop whenever I want it to stop.

Here is the code I use for the sender:

int buttonStartPin = 8;
int buttonEndPin = 9;
int sendStartPin = 6;
int sendEndPin = 7;

void setup() {
pinMode(sendStartPin, OUTPUT);
pinMode(sendEndPin, OUTPUT);
pinMode(buttonStartPin, INPUT);
pinMode(buttonEndPin, INPUT);
}

void loop() {
if (digitalRead(buttonStartPin) == HIGH) {
digitalWrite(sendStartPin, HIGH);
} else {
digitalWrite(sendStartPin, LOW);
}
if (digitalRead(buttonEndPin) == HIGH) {
digitalWrite(sendEndPin, HIGH);
} else {
digitalWrite(sendEndPin, LOW);
}
delay(100);
}

 

Here is the code for the receiver:

#define NOTE_D0 -1
#define NOTE_D1 285
#define NOTE_D2 330
#define NOTE_D3 360
#define NOTE_D4 393
#define NOTE_D5 441
#define NOTE_D6 495
#define NOTE_D7 556

#define NOTE_DL1 147
#define NOTE_DL2 165
#define NOTE_DL3 175
#define NOTE_DL4 196
#define NOTE_DL5 221
#define NOTE_DL6 248
#define NOTE_DL7 278

#define NOTE_DH1 589
#define NOTE_DH2 661
#define NOTE_DH3 700
#define NOTE_DH4 786
#define NOTE_DH5 882
#define NOTE_DH6 990
#define NOTE_DH7 112

#define WHOLE 1
#define HALF 0.5
#define QUARTER 0.25
#define EIGHTH 0.125
#define SIXTEENTH 0.625

int length;
int toneCounter = 0;

int tonePin = 13;
int receiveStartPin = 6;
int receiveEndPin = 7;

bool playStart = false;

int tune[] =
{
NOTE_DH1, NOTE_D6, NOTE_D5, NOTE_D6, NOTE_D0,
NOTE_DH1, NOTE_D6, NOTE_D5, NOTE_DH1, NOTE_D6, NOTE_D0, NOTE_D6,
NOTE_D6, NOTE_D6, NOTE_D5, NOTE_D6, NOTE_D0, NOTE_D6,
NOTE_DH1, NOTE_D6, NOTE_D5, NOTE_DH1, NOTE_D6, NOTE_D0,

NOTE_D1, NOTE_D1, NOTE_D3,
NOTE_D1, NOTE_D1, NOTE_D3, NOTE_D0,
NOTE_D6, NOTE_D6, NOTE_D6, NOTE_D5, NOTE_D6,
NOTE_D5, NOTE_D1, NOTE_D3, NOTE_D0,
NOTE_DH1, NOTE_D6, NOTE_D6, NOTE_D5, NOTE_D6,
NOTE_D5, NOTE_D1, NOTE_D2, NOTE_D0,
NOTE_D7, NOTE_D7, NOTE_D5, NOTE_D3,
NOTE_D5,
NOTE_DH1, NOTE_D0, NOTE_D6, NOTE_D6, NOTE_D5, NOTE_D5, NOTE_D6, NOTE_D6,
NOTE_D0, NOTE_D5, NOTE_D1, NOTE_D3, NOTE_D0,
NOTE_DH1, NOTE_D0, NOTE_D6, NOTE_D6, NOTE_D5, NOTE_D5, NOTE_D6, NOTE_D6,
NOTE_D0, NOTE_D5, NOTE_D1, NOTE_D2, NOTE_D0,
NOTE_D3, NOTE_D3, NOTE_D1, NOTE_DL6,
NOTE_D1,
NOTE_D3, NOTE_D5, NOTE_D6, NOTE_D6,
NOTE_D3, NOTE_D5, NOTE_D6, NOTE_D6,
NOTE_DH1, NOTE_D0, NOTE_D7, NOTE_D5,
NOTE_D6,
};

float duration[] =
{
1, 1, 0.5, 0.5, 1,
0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5,
0.5, 1, 0.5, 1, 0.5, 0.5,
0.5, 0.5, 0.5, 0.5, 1, 1,

1, 1, 1 + 1,
0.5, 1, 1 + 0.5, 1,
1, 1, 0.5, 0.5, 1,
0.5, 1, 1 + 0.5, 1,
0.5, 0.5, 0.5, 0.5, 1 + 1,
0.5, 1, 1 + 0.5, 1,
1 + 1, 0.5, 0.5, 1,
1 + 1 + 1 + 1,
0.5, 0.5, 0.5 + 0.25, 0.25, 0.5 + 0.25, 0.25, 0.5 + 0.25, 0.25,
0.5, 1, 0.5, 1, 1,
0.5, 0.5, 0.5 + 0.25, 0.25, 0.5 + 0.25, 0.25, 0.5 + 0.25, 0.25,
0.5, 1, 0.5, 1, 1,
1 + 1, 0.5, 0.5, 1,
1 + 1 + 1 + 1,
0.5, 1, 0.5, 1 + 1,
0.5, 1, 0.5, 1 + 1,
1 + 1, 0.5, 0.5, 1,
1 + 1 + 1 + 1
};

void setup()
{
pinMode(tonePin, OUTPUT);
pinMode(receiveEndPin, INPUT);
pinMode(receiveStartPin, INPUT);
length = sizeof(tune) / sizeof(tune[0]);
Serial.begin(9600);
}

void loop() {

if (digitalRead(receiveStartPin) == HIGH) {
playStart = true;
}
if (digitalRead(receiveEndPin) == HIGH) {
playStart = false;
toneCounter = 0;
}

if (playStart) {
if (toneCounter < length) {
tone(tonePin, tune[toneCounter]);
delay(400 * duration[toneCounter]);
noTone(tonePin);
toneCounter++;
} else {
toneCounter = 0;
}
}
}

And here are the wire up of our project:

821727939803051953

This is how our project look like:

704744706135651819

And this is a short video about our project:

 

Final Project: Pulse Sensing Wrist Bands | Casey Pan

Participants: Autumn Wu; Emma Quong; Konrad Krawczyk; Casey Pan

Tools: Arduino Uno; Xbee.

Materials: Hard-core wires; conductive threads, felt, etc.

 

When we first got our prompt for the final project: “expanding human senses and expressions”, it seemed pretty broad and hard to find a specific landing point that’s both innovative and practical. We started off by going through the senses that humans don’t have, for example, ultrasound, infrared ray, as well as the expressions human can’t make, such as lights and color-changing. As the discussion went on, we gradually discovered an important factor of the prompt that was earlier overlooked: communication. Human senses are pretty broad and various, but most of them are limited to direct connection, and expanding those senses to a more remote scale can really be something inspiring and mind-changing. After further discussion, we decided on our project: a pair of pulse sensing wrist bands that allows two people check on each other’s heart rate.

 

The ideal outcome of our project would be: both people would be wearing one of the wrist bands, and they will be able to see the other person’s pulse whenever he/she presses a button on the wrist band.

While this story might has a romantic sense in it, it really does have a practical potential use in, for instance, the medical field. If it is fully developed, it will provide a way for care providers to keep an eye on those who might be found in unpredictable dangerous conditions due to health issues.

 

Our project consist of a heavy part of coding, also circuit and fabric carrier building.  I don’t have any background in coding, so I decided to help as much as I can on other parts of the project. I stayed at presence in the lab whenever my other team member is dealing with the code, so I can help with anything else. By helping with building circuits, grabbing materials, testing the code, I tried to make them not distracted by other works beside coding.

Also, though I haven’t yet been able to actually write complicated codes, I tried to participate in the coding process by listening and joining discussions. As an outcome, I can now understand many general ideas of how codes work as well as many methods, and was able to help give suggestions while we were trying to solve some of the problems. This is a precious experience for me, since it gave me the chance to take a peek into the coding world, and it was truly appealing and inspiring.

 

Process outline:

Stage 1: Wireless communication between Arduinos;

Stage 2: LED blinking in response to pulse sensor;

Stage 3: LED blinking in response to pulse sensor on another Arduino (via wireless communication);

Stage 4: Fabric carrier.

 

Process:

Stage 1:

We used Xbees to make two Arduinos communicate with each other wirelessly. The Xbees are connected to the Arduino via Xbee carriers. This made our controller part a little bigger than expected, but we managed to deal with that by removing the Arduino off from the wrist band.

 

One Xbee (attached to computer) sending to another

This video shows how Xbees can talk to each other by writing and reading signals via serial.

The general principle behind this method is to make one Xbee both the signal source and output destination of another. They communicate through serial writing and reading.

Remote control of LED with push buttons.

(Two Arduinos talking to each other via Xbee serial write & serial read. )

After successfully building connection between two Arduinos, we attached the Xbees onto Arduinos using Xbee carrier modules. Then, we built circuits onto the two Arduinos, one with a LED and one with a button. This is a simple model of how wireless control can be done between Arduinos.

 

Problems during stage 1:

While we were trying to build wireless connection between two Arduinos using Xbee, we didn’t notice the tiny switch “USB/XBEE” on Arduinos, which determines whether or not the Xbee will be used as a communication tunnel. This caused a lot of confusion and wasted much of our time, but we managed to resolve it at last.

 

Stage 2:

LED blinking in response to pulse sensor.

We attached the pulse sensor as analog input and LED as digital output onto the Arduino. The pulse sensor detects pulse and sends it to the Arduino as analog signals. The Arduino reads the signals and send digital signals to the LED in response.

 

img_0348 img_0349

 

Stage 3:

 

LED blinking in response to pulse sensor on another Arduino (via wireless communication)

Achieving this stage was pretty hard, because originally the communication between Xbees and the communication between Pulse sensors and LEDs used different methods.

 

OLED display blinking in response to pulse sensor.

After successfully making LEDs blinking in response to pulse sensor on another Arduino via wireless communication, we tried to replace the LEDs with OLED displays, which ideally would not only blink to the wearer’s pulse but also show BPM (beats per minute) at the bottom.

However, we abandoned using OLED display later in the process, because we couldn’t make the displays blink steadily in response to pulse sensors on another Arduino, and the time limit doesn’t allow us to spend more time on resolving this problem. Therefore we agreed to compromise on this detail for the sake of the general outcome of our project.

 

Problem during stage 3:

Since our method of communication was for the Xbees to write and read through serial, problems occurred when we tried to make this a two-sides process. The signals from two pulse sensors blended with each other and caused confusion to the LEDs.

Antonius suggested that we use button to turn on and off the sensors. It worked, but the outcome conflicted with our original story — it turned the function of the wrist bands from checking on someone to sending your own pulse to another person. So I suggested that we could move the buttons from the sending side to the receiving sides, which is the LEDs. But this adjustment won’t prevent the pulse sensors from interrupting each other, so I took this a step forward and suggested that we add four buttons in total, two on each wrist band:

img_0519

 

After some discussion, we agreed that functions No.3 & 4 (Type two) are more of distractions than additions, so we decided to keep and focus on functions No.1 & 2.

Through group discussion, we figured that a more ideal solution to this problem is to use different variables for the two sets of sensors and LEDs. However, this would take a lot of time and effort and we couldn’t make it. But this is a really good potential way of solving this kind of problems.

 

*Circuit with one button:

img_0382

 

Stage 4:

The final stage of our process was to create our actual wrist bands with all the electronics built in. It was a lot of sewing and soldering, and we all helped in this process.

img_0558

img_0559

img_0567

 

Problems during stage 4:

Originally, our wrist band was designed to be all connected with wires. But throughout the process, we found out that since many of the components weren’t originally designed to be put onto wearables, bending and soldering is likely to cause damage.

For instance, our push button’s leg broke off twice cause it wasn’t strong enough to be bended flat. Emma reconnected it with conductive thread. It turned out that soft materials like conductive thread might be much more stable than we imagined, even more stable than hard materials when used properly.

 

Final test:

 

Yay!

 

It worked great during the IMA show, too:

 

* During the IMA Show, one of the pulse sensors stopped working after being pressed hard and repeatedly by one of the visitors. It blinked in response to the pressure while being pressed. I guess this indicates that the way the sensors work has something to do with pressure change.

 

Potential Improvements:

  1. A shortcoming of our project is the unstablity of our sensing part. It often takes some time for the sensors to find a steady pulse. For further improvement, we can use better sensors, or somehow make the sensing area larger (than a dot as it currently is).
  2. Our current wireless communication method is using Xbee, but this added a limit to the maximum of distance. For further improvement, we can try different methods to make long distance communications possible.
  3. The look of the wrist bands can be improved. For instance, making a pocket for the Arduino and a path for all the wires together. This will make our wrist bands more wearable and usable.

 

Overall, the process of building this project with my incredible teammates was an extraordinary and inspiring experience. It left me with a lot to think about, and made me want to keep exploring in the field of IMA.

 

 

 

 

 

Final Project: Panda Operation

Annaluz Cabrera, Flora Lu, Susie Chen, and Xiran Yang

Materials:

  • Black faux fur
  • White terrycloth fur
  • Grey burlap fabric
  • Conductive fabric
  • Felt
  • Black elastic
  • Thread
  • Metal snaps
  • Wire
  • Arduinos (x2)
  • Breadboard
  • MP3 Player
  • Button
  • Digital counters (x2)
  • Memory Card
  • Plywood
  • Lasercutter
  • Carboard
  • Tape
  • Soldering Iron
  • Sewing Machine

Development

Brainstorming: My group and I began our final project by brainstorming ideas that would involve the use of two arduinos, since that was one of the project requirements. Our initial idea was a sort of board game since that would require sending and receiving information. After some deliberation, I suggested we make a sort of Operation Game, after all, that would involve opening and closing circuits, of which we had learned a great deal this semester. The game requires players to remove body parts from holes without injuring the “patient” by touching the edges of the holes. We decided to use a panda figure instead of a human to make the game more unique. This required us to change some of the game pieces to fit the panda idea. Antonius requested that we make the game very large so that it would be more visually pleasing. After some rough sketches, we had a basic idea of what we wanted to do.

Courtesy of Emaze

Courtesy of Emazepanda

Coding: The next step was to code everything. After acquiring the missing hardware such as MP3 players, counters, a memory card, and arduinos, we coded the arduinos so that one would receive information, i.e. recognize each closed circuit depending on the piece that was touched, and another one to send information, or control the countdown and the button used to start the countdown. The extensive coding needed to get these parts to all work together was largely thanks to Susie and Xiran. Flora helped record the messages that the panda would say and these messages were later edited with Audacity in order to make them sound more cartoon-like.

This video was used to help wire the MP3 player: https://www.youtube.com/watch?v=UodfePdNfg8

Box Construction: While working on coding, we also began constructing the box. After designing the panda image on Illustrator and printing it out in order to create a pattern, we constructed a box to house the game. There were no boxes large enough to use on their own, so the team had to construct a larger box out of other pieces. This involved a lot of cutting and even sawing of cardboard pieces. In the end, the box was pretty sturdy and had “bones” to prevent the panda figure from caving in.

img_1452img_1451

Fabric Construction: Once the box was constructed, we moved on to the fabric aspects. We used faux fur to cut the panda shape. Xiran designed the panda parts on Illustrator and used the laser cutter to cut them out of some wood sheets. We then positioned these pieces on the panda and cut the holes where we wanted the pieces to go. We created fur holes by sewing pockets that would hold the pieces. I sewed a giant cover similar to a mattress cover so that the game could easily be taken apart. I made sure to add elastic to the corners so that it would be easy to remove. Once the holes were cut out on the cardboard cover, we were able to put everything together by hot gluing the fur pockets to the cardboard and the panda shape to the fabric cover. Then we sewed conductive fabric onto the edges of the holes. In order to connect the conductive fabric to the hardware, we decided to use snaps and to solder one-half of the snaps to the corresponding wires.

img_1464 img_1453 img_1529

Assembly: We used knitting needles as the chopsticks of the game. The chopsticks are used to remove the pieces from the game. They are conductive and were both connected to the ground. This meant that if either one touched the edge of the hole, the panda would react and speak. To finish, we connected all the hardware to the soft material. The arduinos and breadboard went inside the box and were taped down with conductive tape. The wires were then connected to the conductive fabric through the corresponding snaps. This took a while to figure out since it was difficult to locate which pin each wire was in. We figure it out by trial and error. After snapping everything in place, we just had to make sure all the corners of the cover were firmly attached.

img_1531

Results: Things mostly went as planned. I had one issue near the end once everything was already assembled. The arduinos hadn’t been taped down yet (they were later, per Antonius’ suggestion) and one of the wires became loose. When I reconnected it, I accidentally put it in the 3V pin instead of the 5V pin which caused some malfunctions. However, as soon as he identified the problem, it was easily corrected and the game returned to normal. To improve this project, we could have sewn the edges of the fur panda instead of gluing them, but we were running short on time. We could also have made the panda seem more plush by sewing it against another fabric and inverting it to get rid of rough edges. However, I think we were very successful in the creation of this project and it was very fun to make.

unnamed-22

(Video courtesy of Xiran Yang)

#include "SoftwareSerial.h"
SoftwareSerial mySerial(10, 11);
#include <DFPlayer_Mini_Mp3.h>
# define Start_Byte 0x7E
# define Version_Byte 0xFF
# define Command_Length 0x06
# define End_Byte 0xEF
# define Acknowledge 0x00 //Returns info with command 0x41 [0x01: info, 0x00: no info]

# define ACTIVATED LOW


int bamboo = 3;
int bone2 = 4;
int bone3 = 5;
int bone4 = 6;
int bone5 = 7;
boolean isPlaying = false;



void setup () {

  pinMode(bamboo, INPUT);
  digitalWrite(bamboo, HIGH);
  pinMode(bone2, INPUT);
  digitalWrite(bone2, HIGH);
  pinMode(bone3, INPUT);
  digitalWrite(bone3, HIGH);
  pinMode(bone4, INPUT);
  digitalWrite(bone4, HIGH);
  pinMode(bone5, INPUT);
  digitalWrite(bone5, HIGH);
  mySerial.begin (9600);
  delay(1000);
  isPlaying = false;


}



void loop () {

  if (digitalRead(bamboo) == ACTIVATED)
  {
    if (isPlaying)
    {
      pause();
      isPlaying = false;
    } else
    {
      isPlaying = true;
      playFirst();
      delay(1000);
    }
  }
  if (digitalRead(bone2) == ACTIVATED)
  {
    if (isPlaying)
    {
      pause();
      isPlaying = false;
    } else
    {
      isPlaying = true;
      playSecond();
       delay(1000);
    }
  }
   if (digitalRead(bone3) == ACTIVATED)
  {
    if (isPlaying)
    {
      pause();
      isPlaying = false;
    } else
    {
      isPlaying = true;
      playThird();
       delay(1300);
    }
  }
 if (digitalRead(bone4) == ACTIVATED)
  {
    if (isPlaying)
    {
      pause();
      isPlaying = false;
    } else
    {
      isPlaying = true;
      playFourth();
       delay(1300);
    }
  }
   if (digitalRead(bone5) == ACTIVATED)
  {
    if (isPlaying)
    {
      pause();
      isPlaying = false;
    } else
    {
      isPlaying = true;
      playFifth();
       delay(1200);
    }
  }
}



void pause()
{
  execute_CMD(0x0E, 0, 0);
  delay(500);
}

void playFirst()
{
  execute_CMD(0x03,0,1);

  delay(500);
}
void playSecond()
{
  execute_CMD(0x03,0,2); 
 
  delay(500);
}
void playThird()
{
  execute_CMD(0x03,0,3); 
 
  delay(500);
}
void playFourth()
{
  execute_CMD(0x03,0,4); 
 
  delay(500);
}
void playFifth()
{
  execute_CMD(0x03,0,5); 
 
  delay(500);
}
void setVolume(int volume)
{
  execute_CMD(0x06, 0, volume); // Set the volume (0x00~0x30)
  delay(2000);
}

void execute_CMD(byte CMD, byte Par1, byte Par2)
// Excecute the command and parameters
{
  // Calculate the checksum (2 bytes)
  word checksum = -(Version_Byte + Command_Length + CMD + Acknowledge + Par1 + Par2);
  // Build the command line
  byte Command_line[10] = { Start_Byte, Version_Byte, Command_Length, CMD, Acknowledge,
                            Par1, Par2, highByte(checksum), lowByte(checksum), End_Byte
                          };
  //Send the command line to the module
  for (byte k = 0; k < 10; k++)
  {
    mySerial.write( Command_line[k]);
  }
}

Talking Fabrics Lab: Wearable Buzzer // Hoiyan Guo

Goal: Making a buzzer for the quiz show

Materials: 2 Arduinos, 2 breadboard, fabrics, wires,conductive fabrics, conductive threads

Since Sarabi and I will work together as teammates in our final project, we decided to work together this time as well. With two members, we were required to make use of 2 Arduinos. We wanted to make two finger buttons which turn on the buzzer, and make a giant apron carrying the breadboards and the Arduinos which we could wear together.

First we made a circuit on the breadboard along with a buzzer and a pushbutton.

webwxgetmsgimg-2 webwxgetmsgimg-3

as substitutions for the pushbuttons, we made two pairs of “finger glove”. With conductive fabrics covering the tips.

46906900

When the two fingers touch each other, the buzzer should be turned on. We had an extra piece of normal fabric which is connected to the circuit on the breadboard. We then used conductive threads to connect the fingertips and the fabrics.

The picture shows the connection between the Arduinos

webwxgetmsgimg-4

The codes for the two Arduinos:

// Digital Input/Output between two Arduinos
// by http://antoni.us
int buzzer = 13;
//int button = 8;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(buzzer, OUTPUT);
pinMode(8, INPUT);

// make pin 6 input, 5 output
pinMode(6, INPUT);
pinMode(5, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {

// check if my button is pressed.
if(digitalRead(8) == HIGH){ // if button is pressed, tell the other Arduino.
digitalWrite(5, HIGH);
} else{
digitalWrite(5, LOW);
}

if(digitalRead(6) == HIGH){ // if the input from the other Arduino is HIGH
digitalWrite(buzzer, HIGH); // turn the buzzer on (HIGH is the voltage level)
} else{
digitalWrite(buzzer, LOW); // turn the buzzer off by making the voltage LOW
}
delay(10); // wait

}

 

// Digital Input/Output between two Arduinos
// by http://antoni.us
int buzzer = 13;
//int button = 8;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(buzzer, OUTPUT);
pinMode(8, INPUT);

// make pin 6 input, 5 output
pinMode(6, INPUT);
pinMode(5, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {

// check if my button is pressed.
if(digitalRead(8) == HIGH){ // if button is pressed, tell the other Arduino.
digitalWrite(5, HIGH);
} else{
digitalWrite(5, LOW);
}

if(digitalRead(6) == HIGH){ // if the input from the other Arduino is HIGH
digitalWrite(buzzer, HIGH); // turn the buzzer on (HIGH is the voltage level)
} else{
digitalWrite(buzzer, LOW); // turn the buzzer off by making the voltage LOW
}
delay(10); // wait

}

In the end when we were thinking about how to carry the breadboards and Arduinos with us, we decided to make a giant Apron which we could wear together, and so we did!

The finger gloves weren’t perfectly wearable because they were loose and not very well connected. An improvement that can be made is to make an actual glove for the hand. The pocket we made on the apron was a little small for the breadboard and the Arduinos, and therefore not very optimal for connections. Next time we should measure and test first before making anything!

Sarabi: TF Week 11- Lab 5, Communication Between Arduinos

Partner: Hoiyan

Assignment: Make two Arduinos talk to each other, in preparation for the quiz show.

To create our buzzer, we essentially followed the examples on the class slides. We connected the two arduinos via pins 6&7 and gave them a common ground.  To make the buzzer wearable, we made an apron meant to be worn by both of us.  Originally, the buzzer was to be triggered by two finger pieces, but they weren’t very well sewn so we sounded the buzzer by tapping the two wires together.

 

Displaying mmexport1481684779013.jpg

 

 

// Digital Input/Output between two Arduinos
// by http://antoni.us
int buzzer = 13;
//int button = 8; 

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(buzzer, OUTPUT);
  pinMode(8, INPUT);
  
  // make pin 6 input, 5 output
  pinMode(6, INPUT);
  pinMode(5, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  
  // check if my button is pressed.
  if(digitalRead(8) == HIGH){ // if button is pressed, tell the other Arduino.
    digitalWrite(5, HIGH);
  } else{
    digitalWrite(5, LOW);
  }
  
  if(digitalRead(6) == HIGH){ // if the input from the other Arduino is HIGH
    digitalWrite(buzzer, HIGH);   // turn the buzzer on (HIGH is the voltage level)
  } else{
  digitalWrite(buzzer, LOW);    // turn the buzzer off by making the voltage LOW
  }
  delay(10);               // wait
  
}

Sarabi: TF Week 14- Final Project || Expressive Cloud

Partners: James, Alice, Hoiyan

Task: Create something that gives humans an extra sense and also allows them to express something without using words. Must make two arduinos talk to each other.

My group really struggled with the ideation process of this project. As mentioned in the lab 5 post, we really couldn’t see why you would need two Arduinos to do the things we wanted to do. Even now, I’m pretty sure our project could have been done using one Arduino, but we used two, just to fit the prompt.

While I was looking at the documentation for the Ultrasonic range sensor I saw a project that made cloud out of cotton and colored them from the inside with LEDs. The actual function of the cloud is irrelevant to this project, but here’s the link anyway: LED Cloud

After much discussion, we decided we wanted to express our emotions with LEDs, and per professor suggestion, we decided to read the emotions using gestures. Since we wanted to go with the cloud idea, all of the emotions were to be expressed via different weather states. “Angry” is lightening, “sad” is blue light, and “happy” is white light with a sun that pops up.  To trigger “angry” the wearer needs to make a fist. To trigger “happy” the wearer needs to make a thumbs up, and to trigger “sad” the wearer needs to fold his/her arms across their chest.

Some of the feedback we received while presenting the final was that perhaps the gestures were too obvious. The professors suggested that we could try something more subtle because a thumbs up is obviously a signal of happiness. While I agree with this assertion, the type of people who actually make the thumbs up gesture when they’re happy are probably not the type of people who need our project. Our project is designed for people like the makers. We all have very subtle emotions. It’s not immediately obvious how we’re feeling (and as a result, everyone around us just assumes we’re happy, which is often not the case). Because our project stores the last emotion visible, you don’t need to continue doing the gesture to trigger the response. You can do it once and it will last for 5 or 10 seconds. The idea is that someone can see how you’re feeling without having to ask.

We attached the cloud (with LEDs on the inside) to the rim of a baseball cap, and we attached the sun to a servo which was attached to the inside of the cap. The servo made the hat a little bit uncomfortable, but placing the servo on the outside caused logistical problems with the cloud. These problems could probably be solved with a smaller servo.

After we got all the constituent parts ready, we wired everything and tried the code. It worked, so all we had to do was finish the glove and find a way to hide the wires running from the glove to the hat. Since folding your arms over your chest is one of the gestures, which requires a shirt with a conductive patch, we decided to run the other wires through the sleeve of the shirt as well. The wires come out of the collar of the shirt and plug into the hat.

For some reason, after we reconnected everything, our code ceased to work. I still don’t know what the issue was, but other group members met with the professor and he helped them fix the code. Afterwards our project worked. We realized, though, that since the dress form has a metal head, it interferes with the arduino, causing a lot of noise. When we took the hat off of the dress form, though, it worked more reliably.

   img_3018

 

wechatimg3  webwxgetmsgimg

 

//Sender part
int Out1Pin = 6;
int Out2Pin = 7;

int button1Pin = 9;     //ring finger
int button2Pin = 10;    //thumb
int button3Pin = 11;    //palm

void setup() {
  // put your setup code here, to run once:
  pinMode(Out1Pin, OUTPUT);
  pinMode(Out2Pin, OUTPUT);

  pinMode(button1Pin, INPUT);
  pinMode(button2Pin, INPUT);
  pinMode(button3Pin, INPUT);

  Serial.begin(9600);
}

void loop() {
  Serial.print("1: ");
  Serial.print(digitalRead(button1Pin));
  Serial.print(" ");
  
  Serial.print("2: ");
  Serial.print(digitalRead(button2Pin));
  Serial.print(" ");

  Serial.print("3: ");
  Serial.print(digitalRead(button3Pin));
  Serial.print(" ");

Serial.println();
  // put your main code here, to run repeatedly:
  if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == HIGH) {
    digitalWrite(Out1Pin, HIGH);
    digitalWrite(Out2Pin, LOW);
    Serial.println("angry");
    delay(500);
  }

  else if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == LOW && digitalRead(button3Pin) == LOW) {
    digitalWrite(Out1Pin, LOW);
    digitalWrite(Out2Pin, HIGH);
    Serial.println("happy");
    delay(500);
  }

  else if (digitalRead(button3Pin) == HIGH) {
    digitalWrite(Out1Pin, HIGH);
    digitalWrite(Out2Pin, HIGH);
    Serial.println("sad");
    delay(500);
  }
  // else {
  // digitalWrite(Out1Pin, LOW);
  //digitalWrite(Out2Pin, LOW);
}



  //Receiver part
#include <Servo.h>

Servo myservo;

int incomingByte;

int servoPos = 0;
int myPos = 0;

int WhiteLEDPin = 9;
int YellowLEDPin = 11;
int BlueLEDPin = 10;

int In1Pin = 6;
int In2Pin = 7;

int input1;
int input2;
int lighteningCounter = 0;
int LEDState = 0;

bool happy = false;
bool sad = false;
bool angry = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(WhiteLEDPin, OUTPUT);
  pinMode(YellowLEDPin, OUTPUT);
  pinMode(BlueLEDPin, OUTPUT);

  pinMode(In1Pin, INPUT);
  pinMode(In2Pin, INPUT);

  myservo.attach(12);

  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  input1 = digitalRead(In1Pin);
  input2 = digitalRead(In2Pin);

//  if (Serial.available() > 0) {
//    incomingByte = Serial.read();
//    if (incomingByte == '1') { //Happy Emotion
//      sad = false;
//      angry = false;
//      happy = true;
//    } else if (incomingByte == '2') {  //Sad Emotion
//      happy = false;
//      angry = false;
//      sad = true;
//    } else if (incomingByte == '3') {  //Sad Emotion
//      happy = false;
//      sad = false;
//      angry = true;
//    }
//  }

  if (input1 == HIGH && input2 == LOW) { //Happy Emotion
      sad = false;
      angry = false;
      happy = true;
    } else if (input1 == HIGH && input2 == HIGH) {  //Sad Emotion
      happy = false;
      angry = false;
      sad = true;
    } else if (input1 == LOW && input2 == HIGH) {  //angry Emotion
      happy = false;
      sad = false;
      angry = true;
    }

  if (happy == true) {
    Serial.println("happy");
    digitalWrite(BlueLEDPin, LOW);
    digitalWrite(WhiteLEDPin, HIGH);
    digitalWrite(YellowLEDPin, HIGH);
    if (myPos != 1) {
      myPos --;
      myservo.write(myPos);
      delay(15);
    }
  }
  if (sad == true) {
    Serial.println("sad");
    digitalWrite(BlueLEDPin, HIGH);
    digitalWrite(WhiteLEDPin, LOW);
    digitalWrite(YellowLEDPin, LOW);
    if (myPos != 90) {
      myPos ++;
      myservo.write(myPos);
      delay(15);
    }
  }
  if (angry == true) {
    Serial.println("angry");
    digitalWrite(YellowLEDPin, LOW);
    digitalWrite(BlueLEDPin, LOW);
    if (myPos != 90) {
      myPos ++;
      myservo.write(myPos);
      delay(15);
    }
    if (lighteningCounter <= 12) {
      int abc = random(0, 10);
      if (abc <= 4) {
        digitalWrite(WhiteLEDPin, HIGH);
        delay(50);
        Serial.println(abc);
      } else {
        digitalWrite(WhiteLEDPin, LOW);
        delay(50);
        Serial.println(abc); 

      }
    } else {
      digitalWrite(WhiteLEDPin, LOW);
    }
    if (lighteningCounter >= 14) {
      lighteningCounter = 0;
    }
    lighteningCounter++;
  }
}

Response to The Sound of Summer Running // Hoiyan Guo

As I was reading the beautiful descriptions of the feelings Douglas has for the pair of tennis shoes, I had a pair of sneakers on my feet. My sneakers have been something which are too ordinary in my life,  I know they feel comfortable, but that’s it, I ignore experiencing the feelings when wearing them in such a poetic way. I put them on, step on the bus to school, and walk from classroom to classroom. Being in the city, being away from the nature, I forget how special it is to put on a pair of sneakers and run in the forest or on the grass as fast and happy as I can. A pair of comfortable tennis shoes makes it possible to run and explore, and makes the connection between wearer and the ground closer and better, instead of cutting the connection between people and nature. What feels so great about putting on such a pair of tennis shoes is actually the feelings which remind the wearer of our beautiful nature. Instead of putting on any shoes, when the summer comes again, I’d love to find somewhere which is a distance away from the busy city, run with the trees and other plants barefoot. Then I should put on a pair of shoes, and start to perceive a deeper meaning of them.

Talking Fabrics Final Project: Expressive Cloud // Hoiyan Guo

Documentation for final project – expressive cloud

Goal: make a wearable cloud which can reinforce the expression of emotions

Team Members: Zijie Chen, Sarabi N. Eventide, Alice Guo, Hoiyan Guo

Materials: 2 Arduinos, wires, pinheads, 1 servo, leds, perf board, cotton, 1 baseball cap, 1 shirt, threads, conductive threads, conductive fabrics

For the final project, all four of us in the group agreed that it would be great to create something that can express emotion. Using a cloud to convey different stages of moods would be interesting because being situated in different weather situations, the clouds vary themselves, which is just like people. But in terms of how we should detect the emotion, we changed our ideas constantly. First we wanted to make use of various sensors such as heart rate sensors, but eventually decided it would be too complicated and time-consuming. We were then suggested to detect the emotion through behaviours instead of physiology. It came to us that there are various hand gestures that strongly link to our emotions, instead of detecting emotions, maybe we could give the wearer of the cloud the initiative to choose what emotion he/she wants to convey to others. So eventually we decided to set three emotions corresponding to three hand gestures: thumb-up-happy, fist-angry, having the palm and the elbow touched-sad. To reach our goal, we needed to make a glove which can read the gestures through an Arduino. And since we were required to make use of two Arduinos, we planed to make the Arduino on the glove the sender, and the other Arduino in the vicinity of the cloud the receiver, controlling the cloud to show different reactions. In order to connect the two Arduinos and hide the long wires connecting them as well as connect the elbow and the Arduino attached to the glove.  we thought of having an extra shirt. Later we also found the need to support and carry the cloud and the Arduino, a baseball cap would be a good solution. So that is how we came up with the idea of the whole project- a set of clothing including a glove, which read the hand gestures and provide one Arduino with feedbacks, a baseball cap, which carries the cloud, the other Arduino and other components, and a shirt, which connect the elbow and one Arduino, and the two Arduinos.

I was in charge of the glove, so I’ll go in more details about it. Three pieces of conductive fabrics are attached to the glove on the places of the ring finger, the thumb and the palm. One extra conductive fabric was attached to the elbow. The ring finger is connected to pin1, thumb to pin2, elbow to pin3 and the palm to power. A long wire was hidden under the shirt to connect the elbow. The Arduino was sewed on the glove in the back of the wrist. It was quite challenging to make the wires connecting the pins and the conductive fabrics stable, first I couched them and laid the wired behind the conductive fabrics, but they all fell out during the testing. Then Sarabi suggested a much better method, which is making the uninsulated part of the wires a loop and solder them, then sewing them with conductive threads, then it should stay forever!

The codes of the Arduino as sender are shown below

int Out1Pin = 6;
int Out2Pin = 7;

int button1Pin = 9; //ring finger
int button2Pin = 10; //thumb
int button3Pin = 11; //palm

void setup() {
// put your setup code here, to run once:
pinMode(Out1Pin, OUTPUT);
pinMode(Out2Pin, OUTPUT);

pinMode(button1Pin, INPUT);
pinMode(button2Pin, INPUT);
pinMode(button3Pin, INPUT);

Serial.begin(9600);
}

void loop() {
Serial.print(“1: “);
Serial.print(digitalRead(button1Pin));
Serial.print(” “);

Serial.print(“2: “);
Serial.print(digitalRead(button2Pin));
Serial.print(” “);

Serial.print(“3: “);
Serial.print(digitalRead(button3Pin));
Serial.print(” “);

Serial.println();
// put your main code here, to run repeatedly:
if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == HIGH) {
digitalWrite(Out1Pin, HIGH);
digitalWrite(Out2Pin, LOW);
Serial.println(“angry”);
delay(500);
}

else if (digitalRead(button1Pin) == HIGH && digitalRead(button2Pin) == LOW && digitalRead(button3Pin) == LOW) {
digitalWrite(Out1Pin, LOW);
digitalWrite(Out2Pin, HIGH);
Serial.println(“happy”);
delay(500);
}

else if (digitalRead(button3Pin) == HIGH) {
digitalWrite(Out1Pin, HIGH);
digitalWrite(Out2Pin, HIGH);
Serial.println(“sad”);
delay(500);
}
// else {
// digitalWrite(Out1Pin, LOW);
//digitalWrite(Out2Pin, LOW);
}

There are three reactions in the cloud: Happy – white LEDs hidden in the cloud will be lighted and a sun connected to the servo will rotate and show up; angry – the white LEDs used to create the sunny weather will start blinking in a random order and show thundering; sad- a blue/purple light will be shown. First a mistake was made that we sewed the Arduino inside, making it impossible to wear. We fixed it later. But the servo inside also makes it not comfortable to wear.

646861276 950495613  607148086 webwxgetmsgimg719045667

The codes of the Arduino as receiver are shown here

#include <Servo.h>

Servo myservo;

int incomingByte;

int servoPos = 0;
int myPos = 0;

int WhiteLEDPin = 9;
int YellowLEDPin = 11;
int BlueLEDPin = 10;

int In1Pin = 6;
int In2Pin = 7;

int input1;
int input2;
int lighteningCounter = 0;
int LEDState = 0;

bool happy = false;
bool sad = false;
bool angry = false;

void setup() {
// put your setup code here, to run once:
pinMode(WhiteLEDPin, OUTPUT);
pinMode(YellowLEDPin, OUTPUT);
pinMode(BlueLEDPin, OUTPUT);

pinMode(In1Pin, INPUT);
pinMode(In2Pin, INPUT);

myservo.attach(12);

Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
input1 = digitalRead(In1Pin);
input2 = digitalRead(In2Pin);

// if (Serial.available() > 0) {
// incomingByte = Serial.read();
// if (incomingByte == ‘1’) { //Happy Emotion
// sad = false;
// angry = false;
// happy = true;
// } else if (incomingByte == ‘2’) { //Sad Emotion
// happy = false;
// angry = false;
// sad = true;
// } else if (incomingByte == ‘3’) { //Sad Emotion
// happy = false;
// sad = false;
// angry = true;
// }
// }

if (input1 == HIGH && input2 == LOW) { //Happy Emotion
sad = false;
angry = false;
happy = true;
} else if (input1 == HIGH && input2 == HIGH) { //Sad Emotion
happy = false;
angry = false;
sad = true;
} else if (input1 == LOW && input2 == HIGH) { //angry Emotion
happy = false;
sad = false;
angry = true;
}

if (happy == true) {
Serial.println(“happy”);
digitalWrite(BlueLEDPin, LOW);
digitalWrite(WhiteLEDPin, HIGH);
digitalWrite(YellowLEDPin, HIGH);
if (myPos != 1) {
myPos –;
myservo.write(myPos);
delay(15);
}
}
if (sad == true) {
Serial.println(“sad”);
digitalWrite(BlueLEDPin, HIGH);
digitalWrite(WhiteLEDPin, LOW);
digitalWrite(YellowLEDPin, LOW);
if (myPos != 180) {
myPos ++;
myservo.write(myPos);
delay(15);
}
}
if (angry == true) {
Serial.println(“angry”);
digitalWrite(YellowLEDPin, LOW);
digitalWrite(BlueLEDPin, LOW);
if (myPos != 180) {
myPos ++;
myservo.write(myPos);
delay(15);
}
if (lighteningCounter <= 12) {
int abc = random(0, 10);
if (abc <= 4) {
digitalWrite(WhiteLEDPin, HIGH);
delay(50);
Serial.println(abc);
} else {
digitalWrite(WhiteLEDPin, LOW);
delay(50);
Serial.println(abc);

}
} else {
digitalWrite(WhiteLEDPin, LOW);
}
if (lighteningCounter >= 14) {
lighteningCounter = 0;
}
lighteningCounter++;
}
}

We used three long wires which go through the shirt to connect the two Arduinos, pin6 to pin7, pin7 to pin6, and ground to ground. A later improvement that was made was twisting them to make everything look neater.

176644127

The whole project did work, but it still went wrong sometimes. More should be done to make the connections stable. For example, when the wire doesn’t stay in the pin, it’s a solution to solder it in the connection. And making use of tapes is another way. Other improvements we can make are making the whole project more wearable, hiding the wires better. We were also suggested that the hand gesture for happy and angry are too obvious, from that the reactions of the cloud may be too much. And next time if we keep working on the project, we can also think of using other kinds of hat other than baseball cap, to explore other possibilities of the servos.

My teammates were all very dedicated and helpful. I learned a lot from James and Sarabi, who helped with the coding. And I also gained a lot of support from Alice. It was both a great class and personal experience working on the project, and it was a good ending to the Talking Fabrics class this semester!

Talking Fabrics Final Project: SmartWear (Autumn)

In this final project, our team, Konrad Krawczyk, Casey Pan, Emma Quong and me, aimed to make two-way communication smart wristbands through which people can check each other’s pulses.

Materials we used: Two Arduinos, two Xbees, two Xbee shields, LEDs, Wires, Felt, needles, threads, Velcro, Snaps, and Push buttons.

Xbee: For smart wears, our first problem is wireless communication. We used Xbee in our project, following instructions on these websites: https://www.digi.com/products/xbee-rf-solutions/xctu-software/xctu and http://www.digi.com/blog/videos/xbee-tech-tip-digital-io-line-passing-with-xbee/

We started with making the two Arduino talking with LEDs and Push buttons.

We continued to join the pulse sensors to the Arduinos. We also use push buttons to control the LEDs. Thus, people can check others pulse when them want to.

Emma and Konrad tried to integrate the OLED display. Due to project time constraints, we switched back to the LEDs on the last day.

Emma made a very good design of where the wires, LEDs, sensors should go when moving everything from breadboard to wearable wristbands. We then soldered and sewed everything together.

Problems:

We didn’t pay enough attention to the switches on Xbee shields which prevented Xbee from communicating.

OLED display is really hard, because if A wants to see B’s pulse and BPM, since Xbee communicates through Serial, we have to deal with multiple variables printed in Serial to make sure they do not mix up with each other.

Finally, we have our demo:

 

 

 

 

//  VARIABLES
int pulsePin = 0;                 // Pulse Sensor purple wire connected to analog pin 0
int blinkPin = 13;
int fadePin = 5;
int fadeRate = 0;                 // used to fade LED on with PWM on fadePin
int QS_r = 0;

// these variables are volatile because they are used during the interrupt service routine!
volatile int BPM;                   // used to hold the pulse rate
volatile int Signal;                // holds the incoming raw data
volatile int IBI = 600;             // holds the time between beats, must be seeded!
volatile boolean Pulse = false;     // true when pulse wave is high, false when it's low
volatile boolean QS = false;        // becomes true when Arduoino finds a beat.


void setup() {
  pinMode(fadePin,OUTPUT);
  pinMode(blinkPin,OUTPUT);
  Serial.begin(9600);             // we agree to talk fast!
  interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS
}



void loop() {
  if (QS == false) {
    Serial.print('0');
  } else {
    Serial.print('1');
    QS = false;
  }

  if (Serial.available() > 0) {
    QS_r = Serial.read();
    if (QS_r == '1') {                      // Quantified Self flag is true when arduino finds a heartbeat
      fadeRate = 255;                  // Set 'fadeRate' Variable to 255 to fade LED with pulse
    }
    fadeRate -= 15;                         //  set LED fade value
    fadeRate = constrain(fadeRate, 0, 255); //  keep LED fade value from going into negative numbers!
    analogWrite(fadePin, fadeRate);         //  fade LED//
  }else {
    digitalWrite(fadePin, LOW);
  }
  delay(20);  //  take a break
}


volatile int rate[10];                    // array to hold last ten IBI values
volatile unsigned long sampleCounter = 0;          // used to determine pulse timing
volatile unsigned long lastBeatTime = 0;           // used to find IBI
volatile int P =512;                      // used to find peak in pulse wave, seeded
volatile int T = 512;                     // used to find trough in pulse wave, seeded
volatile int thresh = 512;                // used to find instant moment of heart beat, seeded
volatile int amp = 100;                   // used to hold amplitude of pulse waveform, seeded
volatile boolean firstBeat = true;        // used to seed rate array so we startup with reasonable BPM
volatile boolean secondBeat = false;      // used to seed rate array so we startup with reasonable BPM


void interruptSetup(){     
  // Initializes Timer2 to throw an interrupt every 2mS.
  TCCR2A = 0x02;     // DISABLE PWM ON DIGITAL PINS 3 AND 11, AND GO INTO CTC MODE
  TCCR2B = 0x06;     // DON'T FORCE COMPARE, 256 PRESCALER 
  OCR2A = 0X7C;      // SET THE TOP OF THE COUNT TO 124 FOR 500Hz SAMPLE RATE
  TIMSK2 = 0x02;     // ENABLE INTERRUPT ON MATCH BETWEEN TIMER2 AND OCR2A
  sei();             // MAKE SURE GLOBAL INTERRUPTS ARE ENABLED      
} 


// THIS IS THE TIMER 2 INTERRUPT SERVICE ROUTINE. 
// Timer 2 makes sure that we take a reading every 2 miliseconds
ISR(TIMER2_COMPA_vect){                         // triggered when Timer2 counts to 124
  cli();                                      // disable interrupts while we do this
  Signal = analogRead(pulsePin);              // read the Pulse Sensor 
  sampleCounter += 2;                         // keep track of the time in mS with this variable
  int N = sampleCounter - lastBeatTime;       // monitor the time since the last beat to avoid noise

    //  find the peak and trough of the pulse wave
  if(Signal < thresh && N > (IBI/5)*3){       // avoid dichrotic noise by waiting 3/5 of last IBI
    if (Signal < T){                        // T is the trough
      T = Signal;                         // keep track of lowest point in pulse wave 
    }
  }

  if(Signal > thresh && Signal > P){          // thresh condition helps avoid noise
    P = Signal;                             // P is the peak
  }                                        // keep track of highest point in pulse wave

  //  NOW IT'S TIME TO LOOK FOR THE HEART BEAT
  // signal surges up in value every time there is a pulse
  if (N > 250){                                   // avoid high frequency noise
    if ( (Signal > thresh) && (Pulse == false) && (N > (IBI/5)*3) ){        
      Pulse = true;                               // set the Pulse flag when we think there is a pulse
      digitalWrite(blinkPin,HIGH);                // turn on pin 13 LED
      IBI = sampleCounter - lastBeatTime;         // measure time between beats in mS
      lastBeatTime = sampleCounter;               // keep track of time for next pulse

      if(secondBeat){                        // if this is the second beat, if secondBeat == TRUE
        secondBeat = false;                  // clear secondBeat flag
        for(int i=0; i<=9; i++){             // seed the running total to get a realisitic BPM at startup
          rate[i] = IBI;                      
        }
      }

      if(firstBeat){                         // if it's the first time we found a beat, if firstBeat == TRUE
        firstBeat = false;                   // clear firstBeat flag
        secondBeat = true;                   // set the second beat flag
        sei();                               // enable interrupts again
        return;                              // IBI value is unreliable so discard it
      }   


      // keep a running total of the last 10 IBI values
      word runningTotal = 0;                  // clear the runningTotal variable    

      for(int i=0; i<=8; i++){                // shift data in the rate array
        rate[i] = rate[i+1];                  // and drop the oldest IBI value 
        runningTotal += rate[i];              // add up the 9 oldest IBI values
      }

      rate[9] = IBI;                          // add the latest IBI to the rate array
      runningTotal += rate[9];                // add the latest IBI to runningTotal
      runningTotal /= 10;                     // average the last 10 IBI values 
      BPM = 60000/runningTotal;               // how many beats can fit into a minute? that's BPM!
      QS = true;                              // set Quantified Self flag 
      // QS FLAG IS NOT CLEARED INSIDE THIS ISR
    }                       
  }

  if (Signal < thresh && Pulse == true){   // when the values are going down, the beat is over
    digitalWrite(blinkPin,LOW);            // turn off pin 13 LED
    Pulse = false;                         // reset the Pulse flag so we can do it again
    amp = P - T;                           // get amplitude of the pulse wave
    thresh = amp/2 + T;                    // set thresh at 50% of the amplitude
    P = thresh;                            // reset these for next time
    T = thresh;
  }

  if (N > 2500){                           // if 2.5 seconds go by without a beat
    thresh = 512;                          // set thresh default
    P = 512;                               // set P default
    T = 512;                               // set T default
    lastBeatTime = sampleCounter;          // bring the lastBeatTime up to date        
    firstBeat = true;                      // set these to avoid noise
    secondBeat = false;                    // when we get the heartbeat back
  }

  sei();                                   // enable interrupts when youre done!
}// end isr