{"id":187,"date":"2011-12-08T18:01:19","date_gmt":"2011-12-08T18:01:19","guid":{"rendered":"http:\/\/www.phanv.com\/blog\/?p=187"},"modified":"2011-12-08T18:19:30","modified_gmt":"2011-12-08T18:19:30","slug":"187","status":"publish","type":"post","link":"https:\/\/www.phanv.com\/blog\/187\/","title":{"rendered":"Final Project: Livid Instruments &#8211; Switch"},"content":{"rendered":"<p><div class=\"videoContainer\"><iframe loading=\"lazy\" src=\"http:\/\/player.vimeo.com\/video\/33124817?title=0&amp;byline=0&amp;portrait=0\" frameborder=\"0\" width=\"320\" height=\"176\"><\/iframe><\/div><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads_Livid_Wiki.jpeg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-199\" title=\"byob_keypads_Livid_Wiki\" src=\"http:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads_Livid_Wiki-225x300.jpg\" alt=\"\" width=\"225\" height=\"300\" srcset=\"https:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads_Livid_Wiki-225x300.jpg 225w, https:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads_Livid_Wiki-768x1024.jpg 768w\" sizes=\"auto, (max-width: 225px) 100vw, 225px\" \/><\/a><\/p>\n<p>Soldering Instruction (Thank You!!\u00a0Eric Rosenthal ^^ )<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_push_01_1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-189\" title=\"byob_push_01_1\" src=\"http:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_push_01_1-300x269.jpg\" alt=\"\" width=\"300\" height=\"269\" srcset=\"https:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_push_01_1-300x269.jpg 300w, https:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_push_01_1.jpg 505w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-188\" title=\"byob_keypads\" src=\"http:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads-300x126.jpg\" alt=\"\" width=\"300\" height=\"126\" srcset=\"https:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads-300x126.jpg 300w, https:\/\/www.phanv.com\/blog\/wp-content\/uploads\/2011\/12\/byob_keypads.jpg 473w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<pre>Using this Code:\r\n\r\n\/* switch\r\n *\r\n * Each time the input pin goes from LOW to HIGH (e.g. because of a push-button\r\n * press), the output pin is toggled from LOW to HIGH or HIGH to LOW.  There's\r\n * a minimum delay between toggles to debounce the circuit (i.e. to ignore\r\n * noise).\r\n *\r\n * David A. Mellis\r\n * 21 November 2006\r\n *\/\r\n\r\nint inPin = 2;         \/\/ the number of the input pin\r\nint outPin = 13;       \/\/ the number of the output pin\r\n\r\nint state = HIGH;      \/\/ the current state of the output pin\r\nint reading;           \/\/ the current reading from the input pin\r\nint previous = LOW;    \/\/ the previous reading from the input pin\r\n\r\n\/\/ the follow variables are long's because the time, measured in miliseconds,\r\n\/\/ will quickly become a bigger number than can be stored in an int.\r\nlong time = 0;         \/\/ the last time the output pin was toggled\r\nlong debounce = 200;   \/\/ the debounce time, increase if the output flickers\r\n\r\nvoid setup()\r\n{\r\n  pinMode(inPin, INPUT);\r\n  pinMode(outPin, OUTPUT);\r\n}\r\n\r\nvoid loop()\r\n{\r\n  reading = digitalRead(inPin);\r\n\r\n  \/\/ if the input just went from LOW and HIGH and we've waited long enough\r\n  \/\/ to ignore any noise on the circuit, toggle the output pin and remember\r\n  \/\/ the time\r\n  if (reading == HIGH &amp;&amp; previous == LOW &amp;&amp; millis() - time &gt; debounce) {\r\n    if (state == HIGH)\r\n      state = LOW;\r\n    else\r\n      state = HIGH;\r\n\r\n    time = millis();\r\n  }\r\n\r\n  digitalWrite(outPin, state);\r\n\r\n  previous = reading;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Soldering Instruction (Thank You!!\u00a0Eric Rosenthal ^^ ) &nbsp; &nbsp; Using this Code: \/* switch * * Each time the input pin goes from LOW to HIGH (e.g. because of a push-button * press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There&#8217;s * a minimum delay between toggles to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-physical-computing"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":12,"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/posts\/187\/revisions\/192"}],"wp:attachment":[{"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phanv.com\/blog\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}