{"id":6270,"date":"2020-05-11T09:21:19","date_gmt":"2020-05-11T15:21:19","guid":{"rendered":"http:\/\/gregsowell.com\/?p=6270"},"modified":"2020-05-11T09:21:19","modified_gmt":"2020-05-11T15:21:19","slug":"add-a-tens-unit-to-the-operation-boardgame","status":"publish","type":"post","link":"https:\/\/gregsowell.com\/?p=6270","title":{"rendered":"Add a TENS unit to the Operation boardgame!"},"content":{"rendered":"<p>I decided to make my Operation game a little more exciting\/terrifying, pick your own adjective, by having it shock me when I mess up.  Gotta keep quarantine interesting, no?<\/p>\n<p>The build uses:<\/p>\n<li>The cheapest TENS unit on Amazon\n<li>An Operation game\n<li>An arduino pro mini<\/li>\n<p>Here&#8217;s a video of me playing and building it:<br \/>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/d1dWUWbnlgk\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/p>\n<p>Here&#8217;s the arduino code for your review:<\/p>\n<pre class=\"gs-code\"><code class=\"language-plaintext\">int progLoop = 1; \/\/progressive counter loop.  Also used for standard non prog when at 1\r\nint switchState = 0; \/\/switch read\r\n\r\nvoid setup() {\r\n  \/\/ put your setup code here, to run once:\r\n  \/\/Serial.begin(9600);  \/\/setup the serial port so we can monitor it while testing\r\n  pinMode(2, INPUT_PULLUP);    \/\/ switch\r\n  pinMode(10, OUTPUT);    \/\/ relay\r\n  pinMode(13, OUTPUT);    \/\/ led\r\n}\r\n\r\nvoid loop() {\r\n  int sensorValue = analogRead(A0); \/\/read analog sensor(checking if there is voltage coming from the game.\r\n  switchState = digitalRead(2); \/\/read the pin that the switch is on.\r\n  \/\/ Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):\r\n  float voltage = sensorValue * (5.0 \/ 1023.0); \/\/voltage read.  It is two AA batteries so 3V max\r\n  \/\/Serial.println(voltage); \/\/debug output of serial info for testing\r\n  if (switchState == LOW) {\r\n    progLoop = 1; \/\/reset this so you don&#039;t get wammied once moving the switch LOL\r\n  }\r\n  if (voltage &gt; 2) {\r\n    \/\/voltage is coming from the game, so enable the led and relay\r\n    digitalWrite(10, HIGH);\r\n    digitalWrite(13, HIGH);\r\n    delay(200 * progLoop);  \/\/how long does it sleep - how long are you shocked.  AKA enable tens unit, then sleep for as long as you shoul dbe shocked.\r\n    if (switchState == HIGH) {\r\n      progLoop = progLoop + 1; \/\/if the progressive switch is on, then keep incrementing it each time the game buzzes\r\n    }\r\n  } else {\r\n    \/\/no voltage, so turn the LED\/relay off\r\n    digitalWrite(10, LOW);\r\n    digitalWrite(13, LOW);\r\n  }\r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I decided to make my Operation game a little more exciting\/terrifying, pick your own adjective, by having it shock me when I mess up.\u2026<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45,28],"tags":[],"class_list":["post-6270","post","type-post","status-publish","format-standard","hentry","category-arduino","category-fun"],"_links":{"self":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6270"}],"version-history":[{"count":4,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6270\/revisions"}],"predecessor-version":[{"id":6274,"href":"https:\/\/gregsowell.com\/index.php?rest_route=\/wp\/v2\/posts\/6270\/revisions\/6274"}],"wp:attachment":[{"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gregsowell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}