43626192_715119782183154_563121016385254
ezgif.com-video-to-gif.gif

Sketch:

Lighting Aesthetics:

Process Images:

Covering the strips with the felt and placing on the shirt before sewing them on.

IMG_9264.JPG

Wiring

Testing

Schematic:

Survival Hugging T-Shirt

Overall:

There is a saying by Virginia Satir, a respected family therapist, “We need four hugs a day for survival. We need eight hugs a day for maintenance. We need twelve hugs a day for growth.” This Survival Hugging T-Shirt can provide attention through lights in different colours. It is able to count the hugs from 0 to 4 hugs using an IR proximity sensor.

Introduction of Physical Computing class project

Designed, programmed, made by

Meng-Han (Mohan) Yeh

Code:

  1. /*

  2. Project Title: Survival Hugging T-Shirt

  3. Name: Meng-Han Yeh

  4. Description: Control the 4 LED strips with the IR proximity sensor.

  5. Pin Mapping:

  6. Digital Pin 12 is connecting to Red Strip and controlling the Blue light;

  7. Digital Pin 11 is connecting to Blue Strip and controlling the Yellow light;

  8. Digital Pin 10 is connecting to Yellow Strip and controlling the Purple light;

  9. Digital Pin 8 is connecting to Purple Strip and controlling the Red light;

  10. Analog Input 0 (A0) is reading the IR proximity sensor.

  11. Coding Credit: LedStripColorTester - for LED strips colour changing

  12. */

  13. int photocell = A0; // A0 is reading the IR proximity sensor

  14. bool everHugged = false;

  15. unsigned long timer = 0; // set up the timer

  16. int hugCount = 0;

  17. #include <PololuLedStrip.h>

  18. /* Create names for each of the LED strips and set up the digital pins:

  19. Digital Pin 12 = ledStrip (the outer LED strip) is connecting to Red Strip and controlling the Blue light;

  20. Digital Pin 11 = ledStrip2 (the second LED strip from outside) is connecting to Blue Strip and controlling the Yellow light;

  21. Digital Pin 10 = ledStrip3 (the third LED strip from outside) is connecting to Yellow Strip and controlling the Purple light;

  22. Digital Pin 8 = ledStrip4 (the forth LED strip from outside, the central inside heart) is connecting to Purple Strip and controlling the Red light

  23. */

  24. PololuLedStrip<12> ledStrip; // the biggest heart

  25. PololuLedStrip<11> ledStrip2;

  26. PololuLedStrip<10> ledStrip3;

  27. PololuLedStrip<8> ledStrip4; // the smallest heart

  28. // set up how many LEDs on the strip you would like to control

  29. #define LED_COUNT 60

  30. rgb_color colors[LED_COUNT];

  31. void setup()

  32. {

  33. pinMode(photocell, INPUT); // set up the IR proximity sensor

  34. Serial.begin(115200); // set up the Serial Monitor

  35. }

  36. void loop() {

  37. int readVal; // initialize a new integer to store the photocell value

  38. readVal = analogRead(photocell); // do the analog read and store the value

  39. rgb_color color;

  40. // if (it has been at least 10 seconds since the last hug)

  41. if (millis() >= 10000 + timer) {

  42. if (readVal > 500) { // if the sensor detects the volumne above 500

  43. timer = millis();

  44. hugCount++; // the hugCount will plus one when the sensor detects the volumn above 500

  45. Serial.println (hugCount); // Showing the hugCount in Serial Monitor

  46. }

  47. }

  48. // if (hugCount == 0) => the beginning setting

  49. if (hugCount == 0) {

  50. // ledStrip => blue light

  51. color.red = 51;

  52. color.green = 255;

  53. color.blue = 255;

  54. for (uint16_t i = 0; i < LED_COUNT; i++)

  55. {

  56. colors[i] = color;

  57. }

  58. ledStrip.write(colors, LED_COUNT);

  59. // ledStrip2 => yellow light

  60. color.red = 255;

  61. color.green = 255;

  62. color.blue = 0;

  63. for (uint16_t i = 0; i < LED_COUNT; i++)

  64. {

  65. colors[i] = color;

  66. }

  67. ledStrip2.write(colors, LED_COUNT);

  68. // ledStrip3 => purple light

  69. color.red = 255;

  70. color.green = 0;

  71. color.blue = 204;

  72. for (uint16_t i = 0; i < LED_COUNT; i++)

  73. {

  74. colors[i] = color;

  75. }

  76. ledStrip3.write(colors, LED_COUNT);

  77. // ledStrip4 => red light

  78. color.red = 255;

  79. color.green = 0;

  80. color.blue = 0;

  81. for (uint16_t i = 0; i < LED_COUNT; i++)

  82. {

  83. colors[i] = color;

  84. }

  85. ledStrip4.write(colors, LED_COUNT);

  86. }

  87. // if (hugCount == 1) => first hug

  88. else if (hugCount == 1) {

  89. // ledStrip => turns off

  90. color.red = 0;

  91. color.green = 0;

  92. color.blue = 0;

  93. for (uint16_t i = 0; i < LED_COUNT; i++)

  94. {

  95. colors[i] = color;

  96. }

  97. ledStrip.write(colors, LED_COUNT);

  98. // ledStrip2 => yellow light

  99. color.red = 255;

  100. color.green = 255;

  101. color.blue = 0;

  102. for (uint16_t i = 0; i < LED_COUNT; i++)

  103. {

  104. colors[i] = color;

  105. }

  106. ledStrip2.write(colors, LED_COUNT);

  107. // ledStrip3 => purple light

  108. color.red = 255;

  109. color.green = 0;

  110. color.blue = 204;

  111. for (uint16_t i = 0; i < LED_COUNT; i++)

  112. {

  113. colors[i] = color;

  114. }

  115. ledStrip3.write(colors, LED_COUNT);

  116. // ledStrip4 => red light

  117. color.red = 255;

  118. color.green = 0;

  119. color.blue = 0;

  120. for (uint16_t i = 0; i < LED_COUNT; i++)

  121. {

  122. colors[i] = color;

  123. }

  124. ledStrip4.write(colors, LED_COUNT);

  125. }

  126. // if (hugCount == 2) => second hug

  127. else if (hugCount == 2) {

  128. // ledStrip => turns off

  129. color.red = 0;

  130. color.green = 0;

  131. color.blue = 0;

  132. for (uint16_t i = 0; i < LED_COUNT; i++)

  133. {

  134. colors[i] = color;

  135. }

  136. ledStrip.write(colors, LED_COUNT);

  137. // ledStrip2 => turns off

  138. color.red = 0;

  139. color.green = 0;

  140. color.blue = 0;

  141. for (uint16_t i = 0; i < LED_COUNT; i++)

  142. {

  143. colors[i] = color;

  144. }

  145. ledStrip2.write(colors, LED_COUNT);

  146. // ledStrip3 => purple light

  147. color.red = 255;

  148. color.green = 0;

  149. color.blue = 204;

  150. for (uint16_t i = 0; i < LED_COUNT; i++)

  151. {

  152. colors[i] = color;

  153. }

  154. ledStrip3.write(colors, LED_COUNT);

  155. // ledStrip4 => red light

  156. color.red = 255;

  157. color.green = 0;

  158. color.blue = 0;

  159. for (uint16_t i = 0; i < LED_COUNT; i++)

  160. {

  161. colors[i] = color;

  162. }

  163. ledStrip4.write(colors, LED_COUNT);

  164. }

  165. // if (hugCount == 3) => third hug

  166. else if (hugCount == 3) {

  167. // ledStrip => turns off

  168. color.red = 0;

  169. color.green = 0;

  170. color.blue = 0;

  171. for (uint16_t i = 0; i < LED_COUNT; i++)

  172. {

  173. colors[i] = color;

  174. }

  175. ledStrip.write(colors, LED_COUNT);

  176. // ledStrip2 => turns off

  177. color.red = 0;

  178. color.green = 0;

  179. color.blue = 0;

  180. for (uint16_t i = 0; i < LED_COUNT; i++)

  181. {

  182. colors[i] = color;

  183. }

  184. ledStrip2.write(colors, LED_COUNT);

  185. // ledStrip3 => turns off

  186. color.red = 0;

  187. color.green = 0;

  188. color.blue = 0;

  189. for (uint16_t i = 0; i < LED_COUNT; i++)

  190. {

  191. colors[i] = color;

  192. }

  193. ledStrip3.write(colors, LED_COUNT);

  194. // ledStrip4 => red light

  195. color.red = 255;

  196. color.green = 0;

  197. color.blue = 0;

  198. for (uint16_t i = 0; i < LED_COUNT; i++)

  199. {

  200. colors[i] = color;

  201. }

  202. ledStrip4.write(colors, LED_COUNT);

  203. }

  204. // if (the sensor detects more than 3 hugs), all lights turn off

  205. else {

  206. color.red = 0;

  207. color.green = 0;

  208. color.blue = 0;

  209. for (uint16_t i = 0; i < LED_COUNT; i++)

  210. {

  211. colors[i] = color;

  212. }

  213. ledStrip.write(colors, LED_COUNT);

  214. color.red = 0;

  215. color.green = 0;

  216. color.blue = 0;

  217. for (uint16_t i = 0; i < LED_COUNT; i++)

  218. {

  219. colors[i] = color;

  220. }

  221. ledStrip2.write(colors, LED_COUNT);

  222. color.red = 0;

  223. color.green = 0;

  224. color.blue = 0;

  225. for (uint16_t i = 0; i < LED_COUNT; i++)

  226. {

  227. colors[i] = color;

  228. }

  229. ledStrip3.write(colors, LED_COUNT);

  230. color.red = 0;

  231. color.green = 0;

  232. color.blue = 0;

  233. for (uint16_t i = 0; i < LED_COUNT; i++)

  234. {

  235. colors[i] = color;

  236. }

  237. ledStrip4.write(colors, LED_COUNT);

  238. }

  239. // Update the colors buffer

  240. for (uint16_t i = 0; i < LED_COUNT; i++)

  241. {

  242. colors[i] = color;

  243. }

  244. }