{"id":735,"date":"2016-08-28T07:01:53","date_gmt":"2016-08-27T22:01:53","guid":{"rendered":"http:\/\/jumbleat.com\/?p=735"},"modified":"2017-06-26T19:10:43","modified_gmt":"2017-06-26T10:10:43","slug":"shu_watch_in_arduino_v2","status":"publish","type":"post","link":"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/","title":{"rendered":"&#8221;Shooter&#8221; game on Arduino"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u6b21 [ Contents ]<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69d6352989650\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #757575;color:#757575\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #757575;color:#757575\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69d6352989650\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#Super_easy_barrage_shooting_game_%E2%80%9CSHOOTER%E2%80%9D\" >Super easy barrage shooting game\u00a0\u201cSHOOTER\u201d<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#Minimum_Requirements\" >Minimum Requirements<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#Wiring\" >Wiring<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#How_to_play\" >How to play<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#Tuning\" >Tuning<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#Extend\" >Extend<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#LED\" >LED<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#buzzerpiezo_speaker\" >buzzer(piezo speaker)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#82_Character_LCD_screen%EF%BC%88I2C%EF%BC%89\" >8*2 Character LCD\u00a0screen\uff08I2C\uff09<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#Wiring%EF%BC%88Extended%EF%BC%89\" >Wiring\uff08Extended\uff09<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/#%E2%80%9CSHOOTER%E2%80%9D_Sketch\" >\u201cSHOOTER\u201d\u00a0Sketch<\/a><\/li><\/ul><\/nav><\/div>\n<p><\/p>\n<div id=\"prolog\">\n<p>I have explained about\u00a0<strong><a href=\"https:\/\/jumbleat.com\/2016\/08\/19\/switch_without_chatter\/\" target=\"_blank\" rel=\"noopener\"><span style=\"color: #3366ff;\">&#8220;How to avoid from chattering by a programming&#8221;<\/span><\/a><\/strong>\u00a0in my article, and I made a game sketch as sample.\u00a0I was allowed to further develop it.<!--more--> All you need is a switch. You can play the game by using serial monitor of Arduino IDE. You can also enjoy with children.<\/p>\n<p class=\"mtm\"><em>I wrote <a href=\"https:\/\/jumbleat.com\/2017\/06\/26\/bye-bye_chattering_seriously_library\/\" target=\"_blank\" rel=\"noopener\">a chattering-less switch library<\/a> with &#8220;gauging&#8221; method. <br \/>\n(26.6.2017)<\/em><\/p>\n<\/div>\n<div id=\"chap_1\">\n<h2 class=\"h2_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Super_easy_barrage_shooting_game_%E2%80%9CSHOOTER%E2%80%9D\"><\/span>Super easy barrage shooting game\u00a0\u201cSHOOTER\u201d<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Minimum_Requirements\"><\/span>Minimum Requirements<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>PC Arduino\uff08confirmed operation in the Arduino UNO\uff09 A momentary switch<\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Wiring\"><\/span>Wiring<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It is very simple. No resistor, because of inside pullup. <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-740\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_simple_wiring-1024x683.png\" alt=\"shu_watch_simple_wiring\" width=\"660\" height=\"440\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_simple_wiring-1024x683.png 1024w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_simple_wiring-300x200.png 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_simple_wiring-768x512.png 768w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_simple_wiring.png 1071w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"How_to_play\"><\/span>How to play<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><div class=\"jetpack-video-wrapper\"><iframe loading=\"lazy\" title=\"Arduino\u3067\u30b7\u30e5\u30a6\u30a9\u30c3\u30c1\u3082\u3069\u304d\" width=\"660\" height=\"371\" src=\"https:\/\/www.youtube.com\/embed\/7yLzIZ1FiJM?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<\/p>\n<p>Connect to PC your Arduino and write &#8220;shooter&#8221; sketch.\u00a0Then open Serial monitor in your IDE. Rule is simple. Push the switch a lot of times during 10 seconds. There are 3 count before you start.\uff08Also LED of 13 pin tells you the count.\uff09\u3002Aim a high score. Push a switch for a long time, if you want to cancel the game. Your best score is memorized in EEPROM. So, it remains even if you turn off the electricity. Push a switch before you set power on, if you reset the best score. \u00a0 \u00a0<\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Tuning\"><\/span>Tuning<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>You can adjust balance of chattering by change value of &#8216;PUSH_SHORT&#8217;. You can know the proper value using a sketch below. Chattering is very small value. So check the chattering value not to over &#8216;PUSH_SHORT&#8217;.<\/p>\n<pre class=\"lang:default decode:true\" title=\"Chattering Checker\">#define SW 4\r\n#define PUSH_SHORT 700\r\nunsigned long intvl = 0;\r\n\r\nvoid setup() {\r\n  pinMode(SW, INPUT_PULLUP);\r\n  Serial.begin(9600);\r\n}\r\n\r\nvoid loop() {\r\n  unsigned long gauge = 0;\r\n  while (!digitalRead(SW)) gauge++;\r\n  if (gauge &gt; 1)\r\n  {\r\n    char cate[2][5] = {\"PUSH\", \"CHTT\"};\r\n    bool jdg    = (gauge &lt;= PUSH_SHORT) ? 1 : 0;\r\n    Serial.print(cate[jdg]);\r\n    Serial.print(\":\");\r\n    Serial.println(gauge);\r\n    intvl = millis();\r\n  }\r\n\r\n  if ((millis() - intvl) &gt; 1000)\r\n  {\r\n    Serial.println();\r\n    intvl = millis();\r\n  }\r\n}<\/pre>\n<\/div>\n<div id=\"chap_2\">\n<h2 class=\"h2_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Extend\"><\/span>Extend<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>If you add some parts, you can enjoy it like retro game. <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-742\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch2_ex_parts.jpg\" alt=\"shu_watch2_ex_parts\" width=\"900\" height=\"214\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch2_ex_parts.jpg 900w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch2_ex_parts-300x71.jpg 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch2_ex_parts-768x183.jpg 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"LED\"><\/span>LED<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>LED illumination is fun to know status. It is extend as 13 pin LED.<\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"buzzerpiezo_speaker\"><\/span>buzzer(piezo speaker)<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&#8220;Shooter&#8221; makes several sounds. Those are very cheap sound, but effective. Use resistor if the sound loud.<\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"82_Character_LCD_screen%EF%BC%88I2C%EF%BC%89\"><\/span>8*2 Character LCD\u00a0screen\uff08I2C\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It is more effective if you connect it to LCD.<\/p>\n<h3 class=\"h3_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"Wiring%EF%BC%88Extended%EF%BC%89\"><\/span>Wiring\uff08Extended\uff09<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-751\" src=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_wiring-1024x612.png\" alt=\"shu_watch_wiring\" width=\"660\" height=\"394\" srcset=\"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_wiring.png 1024w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_wiring-300x179.png 300w, https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/shu_watch_wiring-768x459.png 768w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/> \u00a0 Why don&#8217;t you make a portable game by extra battery?<\/p>\n<\/div>\n<div id=\"chap_3\">\n<h2 class=\"h2_HLine mtm mbs\"><span class=\"ez-toc-section\" id=\"%E2%80%9CSHOOTER%E2%80%9D_Sketch\"><\/span>\u201cSHOOTER\u201d\u00a0Sketch<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<pre class=\"lang:default decode:true \" title=\"Shooter Sketch\" data-url=\"https:\/\/jumbleat.com\/wp-content\/uploads\/download\/Arduino_Sketches\/txt\/shu_watch_v2.txt\"><\/pre>\n<\/div>\n<div id=\"epilog\">\n<p>Please enjoy.<\/p>\n<\/div>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Sorry, this entry is only available in \u65e5\u672c\u8a9e. For the sake of viewer convenience, the content is shown below in  &hellip; <a href=\"https:\/\/jumbleat.com\/en\/2016\/08\/28\/shu_watch_in_arduino_v2\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">&#8221;Shooter&#8221; game on Arduino<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":739,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5,2,8],"tags":[70,30,55,68,184,67,185,359,360,72,69,186,71,183,187],"class_list":["post-735","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-diary","category-electric","tag-arduino","tag-chattering","tag-game","tag-shu-watch","tag-simple-game","tag-67","tag-185","tag-359","tag-360","tag-72","tag-69","tag-186","tag-71","tag-183","tag-187"],"jetpack_featured_media_url":"https:\/\/jumbleat.com\/wp-content\/uploads\/2016\/08\/e_catch_shu_watch_v2.jpg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7JALB-bR","jetpack_likes_enabled":false,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts\/735","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/comments?post=735"}],"version-history":[{"count":4,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts\/735\/revisions"}],"predecessor-version":[{"id":7105,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/posts\/735\/revisions\/7105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/media\/739"}],"wp:attachment":[{"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/media?parent=735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/categories?post=735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jumbleat.com\/en\/wp-json\/wp\/v2\/tags?post=735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}