Final Project-Ellen

In this final project, Pearl, Paschal, Jeffrey and I worked together to make the “couple shirts”. This project is meant to express the relationship between a couple A and B: if A needs a hug, she/he will press the button of her shirt. And then the buzzer on the shirt of B will start to scream until B comes to A and the two hug together.

The materials included are: two Arduino boards, one sending the signal and the other receiving; two 220 resistors for the buzzers to work; two buzzers, each attached to one Arduino board; two 10k resistors; two batteries, two cotton shirts, several wires and some conductive fabrics and threads.

The missions were divided to each of us before we started to work. I have the part of getting materials, Paschal and Jeffrey write codes, Pearl sews and fixes the circuits onto the shirts. On Friday I went to the fake market and got two cotton shirts, while Paschal sent the picture of circuits to our group chat. I completed the circuit according to the diagram of Paschal, and the next day we met together and fixed the circuits onto two pieces of fabric. The fabrics then were sewed onto the shirts with batteries on.

/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
const int sensorPin = 8;     // the number of sensor. it is digital
const int output = 13;

int sensorValueSend=0;
int sensorValueReceive=0;
// the setup routine runs once when you press reset:

void setup() {
  // initialize serial c ommunication at 9600 bits per second:
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
  pinMode(output, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  
 
  sensorValueSend = digitalRead(sensorPin);   // read the input from the sensor
  sensorValueReceive=Serial.read(); //read input from the Arduino

  // send the read value to the other Arduino:
  Serial.write(sensorValueSend);

  if (sensorValueSend==LOW ){
    if (sensorValueReceive==LOW){
      digitalWrite(output, LOW);     
    }
    if (sensorValueReceive==HIGH){
      while (sensorValueSend==LOW){
        digitalWrite(output, HIGH);
        sensorValueSend=digitalRead(sensorPin); //read input from the sensor again    
      }
           
    }
  }

  else if (sensorValueSend==HIGH ){
    if (sensorValueReceive==LOW){
      
      digitalWrite(output, LOW);     
    }
    if(sensorValueReceive==HIGH){
       digitalWrite(output, LOW);    
    }
  }
  
 //now compare the send and received values
  delay(10);        // delay in between reads for stability
}

Leave a Reply