# Midterm – Vital Wrestler

Many of my friends are heavy smoker. I had been trying to help my friends quit smoke for awhile, telling them how bad smoking influences their physical abilities. They seemed to be not taking my advice seriously, so I decided to make a device that would help my friend realize how bad smoking is.

When I was running cross country in high school, the coach would brought us balloons and had a competition once a month. Whoever pops the ballon first or has the biggest balloon when the time is up can take the day off. We called the competition “vital wrestling.” I took the idea as an inspiration for my midterm and I decided to make an interactive wrestling statue that lets two players compete by blowing into the fans, and whoever pushes the other player’s hand down wins the game.

Project idea

I pictured my project looking like The Electric Knife Orchestra by Neil Mendoza.

Unfortunately, my 3D printer was broken and the school’s labs were closed during the break. I tried making the hands out of scupley clay, but that did not turn out well, so I decided to cut the complexity and make it into a simply looking game, like the Di-Dah-Dit by Morizot Camile.

### BOM:

Arduino Uno x 1

LED x 7 (1 standalone two 3-combined)

Photocell x 2

Potentiometer x 1

LCD x 1

Buzzer x 1

1/4″ thick wood baord 18 x 24

Water color paint container x 2

### Schematic:

I use motors to represent PC fans as Fritzing doesn’t have any pc icons.

### Code:

 void debug(){ Serial.print("Fan 1 = "); Serial.print(val1); Serial.print("\t"); Serial.print("Fan 2 = "); Serial.print(val2); Serial.print("\t"); Serial.print("Case State = "); Serial.print(caseState); Serial.print("\t"); Serial.print("Button = "); Serial.print(buttonVal); Serial.print("\t"); Serial.print("Photocell 1 = "); Serial.print(photoVal1); Serial.print("\t"); Serial.print("Photocell 2 = "); Serial.print(photoVal2); Serial.println(); }

view raw
debug.ino
hosted with ❤ by GitHub

 void logic() { photoVal1 = analogRead(A4); photoVal2 = analogRead(A5); switch (caseState) { case 0: // buttonVal = 0; // buttonVal = digitalRead(Button); // if (val1 < 80 && val2 < 80 && abs(val1 – val2) <= 2) { // if (limit < 1) { //limit the serial print to print one // Serial.println("Press the button to start!"); // } // digitalWrite(Blue, HIGH); if (limit < 1) { //limit the serial print to print one Serial.println("Press the sensors to start!"); lcd.clear(); lcd.print("Press the sensor"); lcd.setCursor(0, 1); lcd.print("to start!"); } limit = 1; //stop the if statement above if (photoVal1 <= 100 && photoVal2 <= 100) caseState++; //move to next case break; case 1: beginDis(); caseState++; break; case 2: //buttonVal = 0; limit = 0; interval = 100; //measureWin(fadeLevel1, fadeLevel2); timerCal(); analogWrite(LED1, fadeLevel1); analogWrite(LED2, fadeLevel2); if (fadeLevel1 >= 255) { fadeLevel1 = 255; winner = 1; caseState++; } if (fadeLevel2 >= 255) { fadeLevel1 = 255; winner = 2; caseState++; } Serial.print("Fan 1 = "); Serial.print(val1); Serial.print("\t"); Serial.print("Fan 2 = "); Serial.print(val2); Serial.print("\t"); Serial.print("1 = "); Serial.print(fadeLevel1); Serial.print("\t"); Serial.print("2 = "); Serial.print(fadeLevel2); Serial.println(); lcd.clear(); lcd.setCursor(2, 0); lcd.print("P2"); lcd.setCursor(12, 0); lcd.print("P1"); lcd.setCursor(2, 1); lcd.print(fadeLevel2); lcd.setCursor(12, 1); lcd.print(fadeLevel1); break; case 3: if (winner == 1) { analogWrite(LED1, 255); Serial.println("Player one wins!"); lcd.clear(); lcd.print("Player one"); lcd.setCursor(0, 1); lcd.print("wins!"); winTone(); } else { analogWrite(LED2, 255); Serial.println("Player two wins"); lcd.clear(); lcd.print("Player two"); lcd.setCursor(0, 1); lcd.print("wins!"); winTone(); } delay(8000); setTone(2000); caseState++; break; case 4: if (limit < 1) { Serial.println("Press the sensors to restart"); lcd.clear(); lcd.print("Press the sensor"); lcd.setCursor(0, 1); lcd.print("to restart!"); } limit = 1; if (photoVal1 <= 100 && photoVal2 <= 100) reset(); break; } } /*Used to have a servo for measuring who is winning so far, but it was conflicting with the fans so I took it out */ //void measureWin(int x , int y) { // // if (x > y) { // if (x – y <= 90) servo.write((90 + (x – y) / 9)); // else servo.write(180); // // } else if (x < y) { // if (y – x <= 90) servo.write((90 – (y – x) / 9)); // else servo.write(0); // // } else servo.write(90); //}

view raw
logic.ino
hosted with ❤ by GitHub

 ////photocell button (lags the progam so I took it out) //void trigger(int first, int second, int state) { // photoVal1 = analogRead(first); // photoVal2 = analogRead(second); // // if (state == 1) { // if (photoVal1 <= 100 && photoVal2 <= 100) caseState++; // } else { // if (photoVal1 <= 100 && photoVal2 <= 100) reset(); // } //} //reset the game void reset() { fadeLevel1 = 0; fadeLevel2 = 0; limit = 0; //servo.write(90); analogWrite(LED1, fadeLevel1); analogWrite(LED2, fadeLevel2); caseState = 0; }

view raw
reset.ino
hosted with ❤ by GitHub

 //transfer fan analog read data into LED fadelevel void timerCal() { long cTime = millis(); if (cTime – timer1 >= interval) { //debouncing if (val1 != 0) { diff1 = (int)(val1 / 10); //measure how hard player one blows fadeLevel1 += diff1; //apply addup } timer1 = cTime; //reseting timer1 } if (cTime – timer2 >= interval) { //debouncing if (val2 != 0) { diff2 = (int)(val2 / 10); //measure how hard player two blows fadeLevel2 += diff2; //apply addup } timer2 = cTime; //reseting timer2 } }

view raw
timerCal.ino
hosted with ❤ by GitHub

 //custom set tone code for my laziness void setTone(int x) { return (tone(8, x, 10)); } //isolate "begin serial print" for easy edit void beginDis() { Serial.println("Ready!"); lcd.clear(); lcd.setCursor(5, 0); lcd.print("Ready!"); setTone(3000); delay(1500); Serial.println(3); lcd.clear(); lcd.setCursor(7, 0); lcd.print(3); setTone(4000); delay(1000); Serial.println(2); lcd.clear(); lcd.setCursor(7, 0); lcd.print(2); setTone(4000); delay(1000); Serial.println(1); lcd.clear(); lcd.setCursor(7, 0); lcd.print(1); setTone(4000); delay(1000); setTone(2000); lcd.clear(); lcd.setCursor(6, 0); lcd.print("GO!"); Serial.println("GO!"); } //isolate win tone for easy edit void winTone() { tone(8, 1000, 800); delay(100); tone(8, 3500, 1000); }

view raw
tone_and_display.ino
hosted with ❤ by GitHub

 //#include #include LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #define LED1 10 #define LED2 6 #define Blue 13 #define FAN1 A0 #define FAN2 A1 #define Button 2 //Servo servo; int caseState, val1, val2, buttonVal, photoVal1, photoVal2, fadeLevel1, fadeLevel2, interval, winner, pos, limit, diff1, diff2; unsigned long timer1, timer2; void setup() { pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(Blue, OUTPUT); pinMode(Button, INPUT); //servo.attach(5); analogWrite(FAN1, 0); analogWrite(FAN2, 0); lcd.begin(16,2); Serial.begin(9600); } void loop() { val1 = analogRead(FAN1); //analog read fan1 val2 = analogRead(FAN2); //analog read fan2 logic(); debug(); }

view raw
vital_wrestling.ino
hosted with ❤ by GitHub

### Process:

When I got the pc fans, I spent a lot of time searching online for a guide that tells me how to use the fans as analog read devices for the Arduino. I didn’t find any, so I just plugged the power into A10 and A1 and ground to ground and they turned out to be working like regular analog devices and they print out larger number as you blow on them.

I figured that one LED for each player wouldn’t be bright enough to represent the game play, so I soldered three LEDs together to form a brighter indicator.

I added a buzzer to play the game start sounds, winning sounds, and the restart sounds.

Laser cutting the case.

Putting everything together.

The Final Product

### Future Iteration:

For Ayo’s class, I had done some research on vital capacity and percentage of college smoker and I found out that around 1/3 of college students smoke. So I asked a few friends to randomly survey 10 students on their campuses to check if the percentage of college smokers given by the research that I found were right.

Here’s what they got:

Which adds up to 40% of college students smoke, slightly over 1/3.

I also looked up the formula to calculate vital capacity and the chart states the difference in vital capacity between athletes and non athletes.

For the future iteration, I’m thinking of using the function that calculates the vital capacity to control the LED fade levels, and return some real vital capacity values after the game ends.