{"id":561,"date":"2018-01-19T16:30:06","date_gmt":"2018-01-19T15:30:06","guid":{"rendered":"https:\/\/sharedinventions.com\/?p=561"},"modified":"2018-10-25T09:25:17","modified_gmt":"2018-10-25T07:25:17","slug":"diy-usb-pedal-device","status":"publish","type":"post","link":"https:\/\/sharedinventions.com\/?p=561","title":{"rendered":"DIY USB Pedal device"},"content":{"rendered":"<p>Sometimes you just need a special USB device for your computer. As your feet are always free, we wanted have a pedal device. The pedal device can act as a keyboard or as a mouse depending on your needs. <strong>Just think for the ones experience disabilities.<\/strong><\/p>\n<p>In our special case we wanted a device, that can send mouse clicks, when pressing the pedal.<\/p>\n<h2>Explanation<\/h2>\n<p>For small USB projects we have a nice tool called Digispark (with ATMega85). (For the record: We also have the Adafruit Trinket).<\/p>\n<p>The Digispark is like a small brother of the Arduino, but it is especially useful to build cheep USB devices.<\/p>\n<p>Very cheep Digispark clones can be found on online stores.<\/p>\n<p>Costs (at Jan. 2018):<\/p>\n<ul>\n<li><a href=\"https:\/\/rover.ebay.com\/rover\/1\/711-53200-19255-0\/1?icep_id=114&amp;ipn=icep&amp;toolid=20004&amp;campid=5338330151&amp;mpre=https%3A%2F%2Fwww.ebay.com%2Fitm%2F1PCS-Mini-ATTINY85-Micro-USB-Development-Board-for-Digispark-Kickstarter%2F142313917222%3Fhash%3Ditem2122920b26%3Ag%3AZvkAAOSwCU1YyOzZ\">Digispark board<\/a> $1.25<\/li>\n<li><a href=\"https:\/\/rover.ebay.com\/rover\/1\/711-53200-19255-0\/1?icep_id=114&amp;ipn=icep&amp;toolid=20004&amp;campid=5338330151&amp;mpre=https%3A%2F%2Fwww.ebay.com%2Fsch%2Fi.html%3F_from%3DR40%26_trksid%3Dm570.l1313%26_nkw%3DFoot%2BPedal%2BSwitch%26_sacat%3D0%26LH_TitleDesc%3D0%26_osacat%3D0%26_odkw%3DAC220V%2BFoot%2BPedal%2BSwitch\">Pedal<\/a> $2.30<\/li>\n<li><a href=\"https:\/\/rover.ebay.com\/rover\/1\/711-53200-19255-0\/1?icep_id=114&amp;ipn=icep&amp;toolid=20004&amp;campid=5338330151&amp;mpre=https%3A%2F%2Fwww.ebay.com%2Fitm%2F1K-OHM-Logarithmic-Taper-Potentiometer-Pot-A1K-1KA%2F250816495760%3Fhash%3Ditem3a65d40090%3Ag%3AYSwAAOxyemBR58Jb\">Potentiometer<\/a>: $0.30 (can be any kind with 3 legs between 100\u2126 to 100K\u2126)<\/li>\n<\/ul>\n<p><strong>Total costs is: $4<\/strong><\/p>\n<p>The ATMega85 has very limited capabilities. Is is barely enough to fill the needs of this project. We have added a variable resistor (potentiometer) to have some control on the device. This is the schematics of the wiring.<\/p>\n<p><a href=\"https:\/\/sharedinventions.com\/?attachment_id=565\" rel=\"attachment wp-att-565\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-565\" src=\"https:\/\/sharedinventions.com\/wp-content\/uploads\/2018\/01\/Screen-Shot-2018-01-17-at-23.51.41.png\" alt=\"\" width=\"796\" height=\"334\" \/><\/a><\/p>\n<h2>The pedal<\/h2>\n<p>We have bought the pedal online.<\/p>\n<p>To disassemble it, you need to loosen the screw and push out the shaft. It comes with a useless piece of wire, that can be easily removed. As our project will use low power (5V), we are free to use any kind of wire laying around. E.g. this old-school telephone cord can finally find it&#8217;s place.<\/p>\n<p>We also have added a small piece of tubing to act as a bend protector.<\/p>\n<p>It is a bit tricky to close the pedal, but nothing special.<\/p>\n<h2>The case<\/h2>\n<p>For the case you can use any kind of plastic box laying around, but as we have 3D printer, we have printed one.<\/p>\n<p><a href=\"https:\/\/sharedinventions.com\/?attachment_id=566\" rel=\"attachment wp-att-566\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-566\" src=\"https:\/\/sharedinventions.com\/wp-content\/uploads\/2018\/01\/Screen-Shot-2018-01-18-at-00.05.37.png\" alt=\"\" width=\"272\" height=\"262\" \/><\/a><\/p>\n<blockquote><p>You can download the 3D design from here: https:\/\/www.thingiverse.com\/thing:2760718<\/p><\/blockquote>\n<h2>Assembly<\/h2>\n<p>First the Digispark board was mounted on a piece of hardwood (dimensions 27x28x12mm). This will add some weight for the box, so it is less likely to tip.<\/p>\n<p>Then all the connections are to be soldered.<\/p>\n<p>The potentiometer was mounted in the case, and the case were closed.<\/p>\n<h2>Software<\/h2>\n<p>For the software part, you can directly upload the program to the device from the Arduino interface as far you have done the following steps.<\/p>\n<ul>\n<li>Have the appropriate firmware installed to your Digispark board (what in all the cases done in the factory) (See for reference: https:\/\/github.com\/micronucleus\/micronucleus)<\/li>\n<li>Have the Digispark board-manager added to your Arduino IDE (by following the steps in<a href=\"http:\/\/digistump.com\/wiki\/digispark\/tutorials\/connecting\"> http:\/\/digistump.com\/wiki\/digispark\/tutorials\/connecting<\/a>) (Board manager URL: http:\/\/digistump.com\/package_digistump_index.json)Windows users! You also need to <a href=\"https:\/\/github.com\/digistump\/DigistumpArduino\/releases\/download\/1.6.7\/Digistump.Drivers.zip\">install a driver<\/a>.<\/li>\n<\/ul>\n<p>First we have uploaded a code, that helps calibrating the potentiometer values. This code will &#8220;type in&#8221; the current analog values read from the potentiometer.<\/p>\n<blockquote><p>Test program for finding out values: <a href=\"https:\/\/sharedinventions.com\/?attachment_id=576\" rel=\"attachment wp-att-576\">PedalDevice-IoTest<\/a><\/p>\n<p>Actual program: <a href=\"https:\/\/sharedinventions.com\/?attachment_id=569\" rel=\"attachment wp-att-569\">PedalDevice-Click02<\/a><\/p><\/blockquote>\n<p>After that, the clicking code was uploaded, and we are ready to roll. (The code contains a software debouncing solution.)<\/p>\n<h2>Click-hack<\/h2>\n<p>The current program we are using for the device | is a kind of click-hack. It will send rapid clicks. You can\u00a0 set the CPS speed by adjusting the <del>k<\/del>nob on the device. When you turn the knob to the right side, it will send right clicks. On the left side, left clicks are sent.<\/p>\n<p>The internal LED flash-speed denotes the CPS value set.<\/p>\n<p>Disclaimer: Please do not use this solution in online games (where pedal devices are not allowed \ud83d\ude42 ), as you will likely to be banned, but more importantly: Play fair!<\/p>\n<h2>Pitfalls<\/h2>\n<ul>\n<li>The D5 pin of the Digispark was marked as analog input, but it is the reset pin of the ATTiny. So lower values will cause reset. Instead pin D2 should be used.<\/li>\n<li>The analog read of the ATTiny85 is a bit odd. E.g. in our case we used D2 for reading analog values, but for analogRead number 1 was needed to be queried.<\/li>\n<li>Always call the\u00a0DigiMouse.update() method, even when it does not seem to be required.<\/li>\n<\/ul>\n<h2>Video<\/h2>\n<p><iframe loading=\"lazy\" title=\"DIY USB Pedal Device\" width=\"665\" height=\"374\" src=\"https:\/\/www.youtube.com\/embed\/6G-Xhe0twYM?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><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you just need a special USB device for your computer. As your feet are always free, we wanted have a pedal device. The pedal device can act as a keyboard or as a mouse depending on your needs. Just think for the ones experience disabilities. In our special case we wanted a device, that\u2026 <span class=\"read-more\"><a href=\"https:\/\/sharedinventions.com\/?p=561\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":571,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,15,6,12],"tags":[],"class_list":["post-561","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-explained","category-gadgets","category-projects"],"_links":{"self":[{"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/posts\/561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=561"}],"version-history":[{"count":13,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions\/654"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=\/wp\/v2\/media\/571"}],"wp:attachment":[{"href":"https:\/\/sharedinventions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sharedinventions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}