{"id":129,"date":"2013-10-03T23:24:16","date_gmt":"2013-10-04T04:24:16","guid":{"rendered":"http:\/\/www.millamilla.com\/?p=129"},"modified":"2013-10-03T23:54:48","modified_gmt":"2013-10-04T04:54:48","slug":"using-the-tymkrs-turn-me-with-an-arduino","status":"publish","type":"post","link":"https:\/\/www.millamilla.com:443\/?p=129","title":{"rendered":"Using the tymkrs &#8220;Turn Me&#8221; with an Arduino"},"content":{"rendered":"<p>Here is a quick write up on how to use the <a href=\"https:\/\/www.tindie.com\/products\/tymkrs\/tymkrs-turn-me-v1-rotary-encoder-kit\/\">tymkrs &#8220;Turn Me&#8221; rotary encoder<\/a>. \u00a0This supports the &#8220;push down&#8221; feature of the tymkrs kit.<\/p>\n<p><a href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo_bb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-130\" style=\"font-size: 13px; line-height: 19px;\" alt=\"RotaryEncoderDemo_bb\" src=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo_bb-300x228.png\" width=\"300\" height=\"228\" srcset=\"https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo_bb-300x228.png 300w, https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo_bb-1024x778.png 1024w, https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo_bb.png 1818w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\u00a0 \u00a0 \u00a0<a href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/output_window.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-131\" style=\"font-size: 13px; line-height: 19px;\" alt=\"output_window\" src=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/output_window-289x300.png\" width=\"289\" height=\"300\" srcset=\"https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/output_window-289x300.png 289w, https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/output_window.png 364w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/DSC_0249_for_web.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-146\" alt=\"DSC_0249_for_web\" src=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/DSC_0249_for_web-300x200.jpg\" width=\"300\" height=\"200\" srcset=\"https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/DSC_0249_for_web-300x200.jpg 300w, https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/DSC_0249_for_web-1024x682.jpg 1024w, https:\/\/www.millamilla.com:443\/wp-content\/uploads\/2013\/10\/DSC_0249_for_web.jpg 1200w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><a style=\"font-size: 13px; line-height: 19px;\" href=\"http:\/\/fritzing.org\/\">Fritzing\u00a0<\/a><span style=\"font-size: 13px; line-height: 19px;\">Rotary Encoder Part:\u00a0<\/span><a style=\"font-size: 13px; line-height: 19px;\" href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/Rotary-Encoder-with-Knob-bth.fzpz_.zip\">Rotary Encoder with Knob bth.fzpz<\/a><\/p>\n<p><a href=\"http:\/\/fritzing.org\/\">Fritzing\u00a0<\/a>Project:\u00a0<a href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo.fzz.zip\">RotaryEncoderDemo.fzz<\/a><a href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo.fzz\"><br \/>\n<\/a><\/p>\n<p>Arduino (1.5) project:\u00a0<a href=\"http:\/\/ostrich.hedrickfam.com:8081\/wp-content\/uploads\/2013\/10\/RotaryEncoderDemo.ino_.zip\">RotaryEncoderDemo.ino<\/a><\/p>\n<pre class=\"brush: arduino; title: ; notranslate\" title=\"\">\r\n\r\n \/* Read Quadrature Encoder\r\n  * Connect Encoder to Pins encoder0PinA, encoder0PinB, and +5V.\r\n  * http:\/\/playground.arduino.cc\/Main\/RotaryEncoders\r\n  * Sketch by max wolf \/ www.meso.net\r\n  * v. 0.1 - very basic functions - mw 20061220\r\n  * Sketch updated by Brooke Hedrick \/ www.millamilla.com\r\n  * v. 0.2 - Added the &quot;S&quot; pin for encoders with push-down support - bth 09292013\r\n  *        - Put a limit of 255 and 0 in place.  It rolls over automatically at the limits - bth 09292013\r\n  *\r\n  *\/\r\n\r\n int val;\r\n int encoder0PinA = 3;\r\n int encoder0PinB = 4;\r\n int encoder0PinS = 5;\r\n int encoder0PosUp = 0;\r\n int encoder0PosDown = 0;\r\n int encoder0PinALast = LOW;\r\n int n = LOW;\r\n int encoder0UpDown = LOW;\r\n\r\n void setup() {\r\n   pinMode(encoder0PinA,INPUT);\r\n   pinMode(encoder0PinB,INPUT);\r\n   pinMode(encoder0PinS,INPUT);\r\n   Serial.begin (9600);\r\n }\r\n\r\n void loop() {\r\n   encoder0UpDown = digitalRead(encoder0PinS);\r\n   n = digitalRead(encoder0PinA);\r\n   if ((encoder0PinALast == LOW) &amp;&amp; (n == HIGH)) {\r\n     \/\/Serial.print(&quot;up down:&quot;);\r\n     \/\/Serial.println(encoder0UpDown);\r\n     if (digitalRead(encoder0PinB) == LOW) {\r\n       if (encoder0UpDown == LOW) {\r\n         encoder0PosUp--;\r\n         if (encoder0PosUp &lt; 0) {\r\n             encoder0PosUp = 255;\r\n         }\r\n       } else {\r\n         encoder0PosDown--;\r\n         if (encoder0PosDown &lt; 0) {\r\n             encoder0PosDown = 255;\r\n         }\r\n       }\r\n     } else {\r\n       if (encoder0UpDown == LOW) {\r\n         encoder0PosUp++;\r\n         if (encoder0PosUp &gt; 255) {\r\n           encoder0PosUp = 0;\r\n         }\r\n       } else {\r\n         encoder0PosDown++;\r\n         if (encoder0PosDown &gt; 255) {\r\n           encoder0PosDown = 0;\r\n         }\r\n       }\r\n     }\r\n     Serial.print(encoder0PosUp);\r\n     Serial.print(&quot; &quot;);\r\n     Serial.println(encoder0PosDown);\r\n   }\r\n   encoder0PinALast = n;\r\n }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is a quick write up on how to use the tymkrs &#8220;Turn Me&#8221; rotary encoder. \u00a0This supports the &#8220;push down&#8221; feature of the tymkrs kit. \u00a0 \u00a0 \u00a0 Fritzing\u00a0Rotary Encoder Part:\u00a0Rotary Encoder with Knob bth.fzpz Fritzing\u00a0Project:\u00a0RotaryEncoderDemo.fzz Arduino (1.5) project:\u00a0RotaryEncoderDemo.ino \/* Read Quadrature Encoder * Connect Encoder to Pins encoder0PinA, encoder0PinB, and +5V. * http:\/\/playground.arduino.cc\/Main\/RotaryEncoders [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[15],"class_list":["post-129","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-arduino"],"_links":{"self":[{"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=129"}],"version-history":[{"count":9,"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":140,"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions\/140"}],"wp:attachment":[{"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.millamilla.com:443\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}