{"id":1373,"date":"2020-09-24T18:54:53","date_gmt":"2020-09-24T22:54:53","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1373"},"modified":"2020-11-06T10:21:26","modified_gmt":"2020-11-06T15:21:26","slug":"sensing-glove-for-scuba-divers","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1373","title":{"rendered":"Sensing glove for Scuba Divers"},"content":{"rendered":"<h1>Problem<\/h1>\n<p>Diving is an exciting and enjoyable sport. However, it can also be dangerous if the divers are not ware of the condition of their equipment, their companions, and the environment. Most divers are trained to understand their equipment well, but it is still difficult to keep track of one&#8217;s diving buddies and the environment even for experienced divers. It becomes quite difficult to keep track of others when a diving group has 3 people, and it is difficult to know one&#8217;s surrounding when the visibility is low in a cave or at night. Most of the time, the divers have to focus on what is ahead of them. Frequent checking around for people and surrounding would slow down the movement and distract the divers.<\/p>\n<h1>Solution<\/h1>\n<p>I previously saw that LED fibers are now integrated into some designs of the cloths. Therefore, I have this idea that a glove with LED on the back can be used as a sensing\/locating system to tell the divers the positions of their companions of whether there is a rock or hard surface behind them. The idea is that The diver will wear 4 ultrasonic ranger for the front, back, left, and right. When the sensor detects objects in a certain range, a signal will be sent to the glove and shown as a light-up LED.<\/p>\n<figure id=\"attachment_1379\" aria-describedby=\"caption-attachment-1379\" style=\"width: 768px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-1379 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-768x1024.jpg\" alt=\"\" width=\"768\" height=\"1024\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-1200x1600.jpg 1200w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3401-scaled.jpg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption id=\"caption-attachment-1379\" class=\"wp-caption-text\">The sensing glove<\/figcaption><\/figure>\n<p>With the information shown on the divers&#8217; glove, they no longer need to look back or around to check on the situation. More importantly, this will be very useful during night dive when the only visible area is 2-4 m pointed by the flashlight.<\/p>\n<h1>Proof of Concept<\/h1>\n<p>Because of the lack of materials, I only use 1 ultrasonic sensor to stimulate the function of one of the four ultrasonic sensor. I originally planned to use a LED matrix as it is more accurate to the original design. But LEDs were used instead because I cannot get one of the LED matrix. The LEDs represent the angle or direction of the detected object, with the bottom LED being 0-30 degree and the top LED being 150-180 degree. Ideally, the distance is reflected by the distance of the light-up LED from the center block. The servo motor is used to rotate the ultrasonic sensor so that objects from a wider range of angles can be detected.<\/p>\n<figure id=\"attachment_1381\" aria-describedby=\"caption-attachment-1381\" style=\"width: 768px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" class=\"wp-image-1381 size-large\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-768x1024.jpg\" alt=\"\" width=\"768\" height=\"1024\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-768x1024.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-225x300.jpg 225w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-1152x1536.jpg 1152w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-1536x2048.jpg 1536w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-1200x1600.jpg 1200w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3399-scaled.jpg 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><figcaption id=\"caption-attachment-1381\" class=\"wp-caption-text\">The set up of the hardware<\/figcaption><\/figure>\n<p><a>Turning sensor<\/a><\/p>\n<p>I used my hand to hold the ultrasonic sensor for the stimulation because the jumpers on the sensor stop the servo motor from moving freely. I tried to mimic the rotation made by the servo motor, but error still occurs as my hand cannot synchronize perfectly with the servo motor .<\/p>\n<p><a href=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/IMG_3397.mov\">Demo of the device<\/a><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-large wp-image-1384\" src=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/Untitled-Sketch_schem-1024x605.jpg\" alt=\"\" width=\"840\" height=\"496\" srcset=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/Untitled-Sketch_schem-1024x605.jpg 1024w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/Untitled-Sketch_schem-300x177.jpg 300w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/Untitled-Sketch_schem-768x454.jpg 768w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/Untitled-Sketch_schem-1200x709.jpg 1200w, https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/wp-content\/uploads\/2020\/09\/Untitled-Sketch_schem.jpg 1437w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>Code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;NewPing.h&gt;\r\n#include &lt;Servo.h&gt;\r\n\r\n#define TRIGGER_PIN  12  \/\/ Arduino pin tied to trigger pin on the ultrasonic sensor.\r\n#define ECHO_PIN     11  \/\/ Arduino pin tied to echo pin on the ultrasonic sensor.\r\n#define MAX_DISTANCE 100 \/\/ Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.\r\n#define SERVO_PIN 10\r\n#define LED_0  2\r\n#define LED_30  3\r\n#define LED_60  4\r\n#define LED_90  5\r\n#define LED_120  6\r\n#define LED_150  7\r\n\r\n\r\nNewPing Sonar_1(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); \/\/ NewPing setup of pins and maximum distance.\r\n\r\nServo Servo1; \/\/ you can call the servo whatever you want\r\n\r\n\/\/Timer\r\n\/\/Clock 1 is the timer for the servo\r\nunsigned long clock1 = 0; \/\/ variable for timing\r\nconst int INTERVAL1 = 5; \/\/ milliseconds between updates\r\n\r\n\/\/Global variables\r\nint angle;\r\nbool bounce = true;\r\n\r\nint direc_distance[181];\r\nint angle_of_objects[10];\r\n\r\n\/\/Functions\r\n\/\/Sweeping the servo motor\r\nvoid sweep_servo() {\r\n  if (bounce == true) {\r\n    angle = angle + 1;\r\n    Servo1.write(angle);\r\n\r\n    dir_dis(angle);\r\n\r\n    if (angle == 180) {\r\n      bounce = false;\r\n\r\n      clear_position();\r\n\r\n\r\n\r\n      \/\/Serial.print(\"0-180: \");\r\n      check_position();\r\n\r\n\r\n      Serial.println(angle_of_objects[0]);\r\n      \/\/Serial.println(angle_of_objects[1]);\r\n      show_position();\r\n\r\n\r\n    }\r\n    return;\r\n  }\r\n\r\n  if (bounce == false) {\r\n    angle = angle - 1;\r\n    Servo1.write(angle);\r\n    dir_dis(angle);\r\n\r\n    if (angle == 0) {\r\n      bounce = true;\r\n      clear_position();\r\n\r\n      \/\/Serial.print(\"180-0: \");\r\n      check_position();\r\n\r\n      Serial.println(angle_of_objects[0]);\r\n      \/\/Serial.println(angle_of_objects[1]);\r\n\r\n      show_position();\r\n\r\n\r\n    }\r\n\r\n  }\r\n\r\n\r\n}\r\n\r\n\/\/The function that records the angle and the distance to the array direc_distance\r\nvoid dir_dis (int angle) {\r\n\r\n  direc_distance[angle] = Sonar_1.ping_cm();\r\n}\r\n\r\nvoid check_position() {\r\n  \/\/The for loop to find the angles of the locations of the objects\r\n\r\n  int index;\r\n  \/\/Serial.print(direc_distance[0]);\r\n  for (int i; i &lt; 181; i++) {\r\n    int start_angle;\r\n    int end_angle;\r\n    int mid_angle;\r\n\r\n    if (direc_distance[i] != 0) {\r\n      start_angle = i;\r\n\r\n      \/\/Serial.print(i);\r\n      \/\/Serial.print(\",start angle:\");\r\n\r\n      while (direc_distance[i] != 0 and abs(direc_distance[i + 1] - direc_distance[i]) &lt; 20) {\r\n        i = i + 1;\r\n        \/\/Serial.println(direc_distance[i]);\r\n        if (i == 180) {\r\n          break;\r\n        }\r\n      }\r\n      end_angle = i;\r\n\r\n      mid_angle = (end_angle - start_angle) \/ 2;\r\n\r\n\r\n      \/\/Serial.println(start_angle);\r\n      \/\/Serial.print(\",end angle:\");\r\n      \/\/Serial.print(end_angle);\r\n      \/\/Serial.print(\",mid angle:\");\r\n      \/\/Serial.println(mid_angle);\r\n\r\n      \/\/Serial.print(\"This is mid angle:\");\r\n      \/\/Serial.println(mid_angle);\r\n      angle_of_objects[index] = mid_angle;\r\n      if (index = 9) {\r\n        return;\r\n      }\r\n      index = index + 1;\r\n    }\r\n\r\n  }\r\n}\r\n\r\nvoid light_LED(int angle) {\r\n  if (angle == 0) {\r\n    digitalWrite(LED_0, HIGH);\r\n  }\r\n\r\n  if (angle == 30) {\r\n    digitalWrite(LED_30, HIGH);\r\n  }\r\n\r\n  if (angle == 60) {\r\n    digitalWrite(LED_60, HIGH);\r\n  }\r\n\r\n  if (angle == 90) {\r\n    digitalWrite(LED_90, HIGH);\r\n  }\r\n\r\n  if (angle == 120) {\r\n    digitalWrite(LED_120, HIGH);\r\n  }\r\n\r\n  if (angle == 150) {\r\n    digitalWrite(LED_150, HIGH);\r\n  }\r\n\r\n \r\n\r\n}\r\n\r\nint select_angle(int angle) {\r\n  if (angle &lt; 30) {\r\n    return 0;\r\n  }\r\n\r\n  if (angle &gt;= 30 and angle &lt; 60) {\r\n    return 30;\r\n  }\r\n\r\n\r\n  if (angle &gt;= 60 and angle &lt; 90) {\r\n    return 60;\r\n  }\r\n\r\n  if (angle &gt;= 90 and angle &lt; 120) {\r\n    return 90;\r\n  }\r\n\r\n  if (angle &gt;= 120 and angle &lt; 150) {\r\n    return 120;\r\n  }\r\n\r\n  if (angle &gt;= 150 and angle &lt; 180) {\r\n    return 150;\r\n  }\r\n}\r\n\r\n\r\n\r\nvoid show_position() {\r\n  \/\/Turns off all the LED lights\r\n  digitalWrite(LED_0, LOW);\r\n  digitalWrite(LED_30, LOW);\r\n  digitalWrite(LED_60, LOW);\r\n  digitalWrite(LED_90, LOW);\r\n  digitalWrite(LED_120, LOW);\r\n  digitalWrite(LED_150, LOW);\r\n\r\n\r\n  int angles[] = {0, 30, 60, 90, 120, 150, 180};\r\n\r\n  for (int i; i &lt; 10; i++) {\r\n    if (angle_of_objects[i] == 0) {\r\n      Serial.println(\"Done\");\r\n      return;\r\n    }\r\n\r\n\r\n    int angle_light = select_angle(angle_of_objects[i]);\r\n\r\n\r\n\r\n    Serial.println(angle_light);\r\n    light_LED(angle_light);\r\n  }\r\n}\r\n\r\n\/\/This function clears the stored angles of the positions of the objects\r\nvoid clear_position() {\r\n  for (int i; i &lt; 10; i++) {\r\n    angle_of_objects[i] = 0;\r\n  }\r\n}\r\n\r\nvoid setup() {\r\n  pinMode(LED_0, OUTPUT);\r\n  pinMode(LED_30, OUTPUT);\r\n  pinMode(LED_60, OUTPUT);\r\n  pinMode(LED_90, OUTPUT);\r\n  pinMode(LED_120, OUTPUT);\r\n  pinMode(LED_150, OUTPUT);\r\n \r\n\r\n  Servo1.attach(SERVO_PIN);\r\n\r\n  Serial.begin(115200); \/\/ Open serial monitor at 115200 baud to see ping results.\r\n\r\n  Servo1.write(0);\r\n  \/\/digitalWrite(LED_180, HIGH);\r\n  delay(2000);\r\n\r\n\r\n\r\n}\r\n\r\nvoid loop() {\r\n\r\n\r\n\r\n\r\n  \/\/The servo clock\r\n  if (millis() &gt;=  clock1) {\r\n    \/\/decreases the minute value in the timer for each task\r\n    sweep_servo();\r\n\r\n    clock1 = millis() + INTERVAL1 ;\r\n\r\n    \/\/Serial.println(angle_of_objects[0]);\r\n\r\n\r\n  }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Diving is an exciting and enjoyable sport. However, it can also be dangerous if the divers are not ware of the condition of their equipment, their companions, and the environment. Most divers are trained to understand their equipment well, but it is still difficult to keep track of one&#8217;s diving buddies and the environment &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/?p=1373\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sensing glove for Scuba Divers&#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":[13],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1373"}],"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=1373"}],"version-history":[{"count":8,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1373\/revisions"}],"predecessor-version":[{"id":1804,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=\/wp\/v2\/posts\/1373\/revisions\/1804"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/48-339\/f2020\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}