{"id":1712,"date":"2020-10-27T17:39:32","date_gmt":"2020-10-27T21:39:32","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1712"},"modified":"2020-10-27T19:13:10","modified_gmt":"2020-10-27T23:13:10","slug":"shadow-boxing-partner","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1712","title":{"rendered":"Shadow Boxing Partner"},"content":{"rendered":"<h1>Problem<\/h1>\n<p>I have just started practicing boxing a few weeks ago and every week we work on a new drill. During class I can work with a partner and get familiar with the hits and rhythm of the drill. After I am familiar with drill, I will have to react to the movement made by my partner and execute the drill accordingly. When I shadow-box in home and without a partner, however, there is no hint or reminder on the next hit as I try to get familiar with the drill again. In addition, shadow-boxing also lacks the reacting aspect of s?m.parring. Therefore, a device that acts as the shadow boxing partner is designed.<\/p>\n<h1>Solution<\/h1>\n<figure id=\"attachment_1715\" aria-describedby=\"caption-attachment-1715\" style=\"width: 840px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-1715 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-1024x768.jpg\" alt=\"\" width=\"840\" height=\"630\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3519-1200x900.jpg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption id=\"caption-attachment-1715\" class=\"wp-caption-text\">The design of the devices<\/figcaption><\/figure>\n<p>The device is made up by six speakers that sticks to the wall. Each square in the diagram above represents a speaker. The diagram shows the default arrangement of the speakers. The number written near the speakers\u00a0 represents the number for the hit the speakers are responsible for. For example, when a jab needs to be thrown, the speaker on the top left-corner will play the sound effect because the number of jab is 1. The middle speakers are responsible to upper cut to chin and body shots to the middle. The device will connect to phone, and the sound effect player by the speakers depending on what drill is being practiced. The one of the navy drills, for example, includes a left hook (3), a straight punch (2), and then a left hook (3). The speaker that is responsible for left hook will play the sound effect for left hook, and the speaker responsible for straight punch will play the sound effect for straight punch. The sound effects of each type of punches are recorded from actual punches. They might not be that distinct comparing to each other but the position of the speaker already gives a big hint on the next hit and the user should at least know what hits are included in the drill.\u00a0When the user gets comfortable with the drill, the device can be switched to difficult mode. Only the first punch or the &#8220;hit&#8221; from the partner is given and the user has to react to it. The user can also change the drill through the smart phone.<\/p>\n<h1>Proof of Logic<\/h1>\n<figure id=\"attachment_1720\" aria-describedby=\"caption-attachment-1720\" style=\"width: 840px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-1720 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-1024x768.jpg\" alt=\"\" width=\"840\" height=\"630\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-1024x768.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-300x225.jpg 300w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-768x576.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-1536x1152.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-2048x1536.jpg 2048w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/10\/IMG_3520-1200x900.jpg 1200w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><figcaption id=\"caption-attachment-1720\" class=\"wp-caption-text\">The demo of the device<\/figcaption><\/figure>\n<p>Because of the lack of materials, I cannot make the full device with 6 speakers. Instead, I will use speaker, solenoid, and vibration motor to stimulate the sound effects for hook, straight punch\/ jab, and body shoots. The first button on the right hand side is to switch between drills and the second button is to switch between normal mode and difficult mode.<\/p>\n<p><iframe title=\"Demonstration of normal mode\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/meQIK1tFc_A?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p><iframe title=\"Demonstration of difficult mode\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/kK2g-vv0QOM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>Code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">\/\/libary\r\n#include \"pitches.h\"\r\n\r\n\r\n\/\/Defining the pins\r\n#define solenoide 12\r\n#define motor 13\r\n#define speaker 7\r\n\r\n#define drill_pin 3\r\n#define hint_pin 2\r\n\r\n\/\/Global varibales\r\n\/\/For interrupt\r\nconst bool isInterrupt = true;\r\nint drill;\r\nint drill_number = 1;\r\nbool hint_status = true;\r\nbool solenoid = true;\r\nint delay_in_between = 350;\r\n\r\n\/\/Functions\r\nvoid move_solenoid() {\r\n  if (solenoid == true) {\r\n    digitalWrite(solenoide, HIGH);\r\n    solenoid = false;\r\n  }\r\n\r\n  else {\r\n    digitalWrite(solenoide, LOW);\r\n    solenoid = true;\r\n  }\r\n}\r\n\r\nvoid vibrate_motor() {\r\n  digitalWrite(motor, HIGH);\r\n  delay(300);\r\n  digitalWrite(motor, LOW);\r\n}\r\n\r\nvoid DrillSwitchPressed() {\r\n  if (digitalRead(drill_pin) == LOW) {\r\n    drill == drill_number ? drill = 0 : drill ++;\r\n  }\r\n}\r\n\r\n\r\nvoid HintSwitchPressed() {\r\n  if (digitalRead(hint_pin) == LOW) {\r\n    hint_status = !hint_status;\r\n  }\r\n}\r\n\r\n\/\/Functions for the drill\r\nvoid Navy_drill(int random_numb) {\r\n  if (hint_status == true) {\r\n    if (random_numb == 1) {\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4,200);\r\n      delay(delay_in_between);\r\n      move_solenoid();\r\n      delay(delay_in_between);\r\n      tone(speaker, NOTE_A4,200);\r\n     \r\n      \r\n    }\r\n\r\n    if (random_numb == 2) {\r\n      move_solenoid();\r\n      delay(delay_in_between);\r\n      tone(speaker, NOTE_A4,200);\r\n      delay(delay_in_between);\r\n      move_solenoid();\r\n    }\r\n\r\n    if (random_numb == 3) {\r\n      \/\/Upper cut\r\n      vibrate_motor();\r\n      delay(delay_in_between);\r\n      move_solenoid();\r\n      delay(delay_in_between);\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4,200);\r\n      \r\n    }\r\n\r\n    if (random_numb == 4) {\r\n      \/\/Upper cut\r\n      \/\/tone(speaker, NOTE_C4);\r\n      \/\/delay(200);\r\n      \/\/tone(speaker, NOTE_D4);\r\n      \/\/delay(100);\r\n      \/\/tone(speaker, NOTE_E4, 100);\r\n      vibrate_motor();\r\n      delay(delay_in_between);\r\n      \/\/hook\r\n      tone(speaker, NOTE_A4, 200);\r\n      delay(delay_in_between);\r\n      move_solenoid();\r\n    }\r\n  }\r\n\r\n  else {\r\n    if (random_numb == 1) {\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4, 200);\r\n      \r\n    }\r\n\r\n    if (random_numb == 2) {\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4, 200);\r\n    }\r\n\r\n    if (random_numb == 3) {\r\n      \/\/Body shot coming in\r\n      vibrate_motor();\r\n    }\r\n\r\n    if (random_numb == 4) {\r\n      \/\/Body shot coming in\r\n      vibrate_motor();\r\n    }\r\n  }   \r\n}\r\n\r\n\r\nvoid Dodge_drill(int random_numb) {\r\n  if (hint_status == true) {\r\n    if (random_numb == 1) {\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4,200);\r\n      delay(delay_in_between);\r\n      move_solenoid();\r\n    }\r\n\r\n    if (random_numb == 2) {\r\n      tone(speaker, NOTE_A4,200);\r\n      delay(delay_in_between);\r\n      move_solenoid();\r\n      \r\n    }\r\n  }\r\n\r\n  else {\r\n    delay(random(0,2000));\r\n    if (random_numb == 1) {\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4, 200);\r\n      \r\n    }\r\n\r\n    if (random_numb == 2) {\r\n      \/\/NOTE_A4 is the note for hook\r\n      tone(speaker, NOTE_A4, 200);\r\n    }\r\n  }   \r\n}\r\nvoid setup() {\r\n  \/\/ Setup the pin modes\r\n  pinMode(solenoide, OUTPUT);\r\n  pinMode(motor, OUTPUT);\r\n\r\n  \/\/When the buttons are pushed, digitalRead shows 0\r\n\r\n  pinMode(drill_pin, INPUT_PULLUP);\r\n  pinMode(hint_pin, INPUT_PULLUP);\r\n\r\n\r\n  \/\/Initiate the serial monitor\r\n  Serial.begin(9600);\r\n\r\n\r\n  \/\/ attach the interrupt pin to a method\r\n  if (isInterrupt) {\r\n    attachInterrupt (digitalPinToInterrupt(drill_pin), DrillSwitchPressed, FALLING);\r\n    attachInterrupt (digitalPinToInterrupt(hint_pin), HintSwitchPressed, FALLING);\r\n  }\r\n\r\n\r\n\r\n \r\n  \/\/vibrate_motor();\r\n  \/\/tone(speaker, NOTE_C4);\r\n  \/\/delay(200);\r\n  \/\/tone(speaker, NOTE_D4);\r\n  \/\/delay(100);\r\n  \/\/tone(speaker, NOTE_E4, 100);\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\nvoid loop() {\r\n  if (drill == 0) {\r\n    \/\/randomSeed(analogRead(A0));\r\n    int random_numb = random(1,4);\r\n    Navy_drill(random_numb);\r\n    delay(3000);\r\n  }\r\n\r\n  if (drill == 1) {\r\n    \/\/randomSeed(analogRead(A0));\r\n    int random_numb = random(1,2);\r\n    Dodge_drill(random_numb);\r\n    delay(4000);\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem I have just started practicing boxing a few weeks ago and every week we work on a new drill. During class I can work with a partner and get familiar with the hits and rhythm of the drill. After I am familiar with drill, I will have to react to the movement made by &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1712\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Shadow Boxing Partner&#8221;<\/span><\/a><\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1712"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1712"}],"version-history":[{"count":4,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1712\/revisions"}],"predecessor-version":[{"id":1742,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1712\/revisions\/1742"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}