{"id":146,"date":"2012-12-06T00:29:10","date_gmt":"2012-12-06T08:29:10","guid":{"rendered":"http:\/\/robertbyam.com\/ces\/?p=146"},"modified":"2025-03-18T14:26:19","modified_gmt":"2025-03-18T22:26:19","slug":"teensy-2-0","status":"publish","type":"post","link":"https:\/\/robertbyam.com\/ces\/2012\/12\/06\/teensy-2-0\/","title":{"rendered":"Teensy 2.0"},"content":{"rendered":"<p>The Teensy 2.0 showed up in the mail today!\u00a0 Here it is, nice and small:<\/p>\n<p><a href=\"http:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8416.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-144\" title=\"Teensy Test\" src=\"http:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8416-400x266.jpg\" alt=\"Teensy Test\" width=\"400\" height=\"266\" srcset=\"https:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8416-400x266.jpg 400w, https:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8416-1024x682.jpg 1024w, https:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8416.jpg 1280w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>It took me less than two hours to get a working gamepad in both Windows and Linux.\u00a0 I had found <a href=\"http:\/\/www.slashdev.ca\/2011\/10\/20\/snes-usb-gamepad\/\">some code online<\/a> that modified Teensy&#8217;s keyboard example to be an SNES gamepad, so a lot of the work was already done.\u00a0 However, the NES and SNES controllers have a chip that communicates over 4 wires to the console using a simple protocol.\u00a0 (I&#8217;ll include some fun trivia about the NES\/SNES at the end of this post). This code I found used that protocol to communicate with the chip inside the controller.\u00a0 In order to make my gamepads all consistent and not have to worry about timing with the NES chip\/protocol, I stripped all of that out and modified it to manually read from the Teensy&#8217;s input pins, one for each button.<\/p>\n<p>Once I got it all working, I could plug the USB port in and have a gamepad with 2 axis and 8 buttons (just like the SNES).\u00a0 And I verified that I could use whatever name I want the gamepad to show up as:<\/p>\n<p><a href=\"http:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8417.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-145\" title=\"Teensy Gamepad Test\" src=\"http:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8417-400x315.jpg\" alt=\"Teensy Gamepad Test\" width=\"400\" height=\"315\" srcset=\"https:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8417-400x315.jpg 400w, https:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8417-1024x806.jpg 1024w, https:\/\/robertbyam.com\/ces\/wp-content\/uploads\/2012\/12\/IMG_8417.jpg 1280w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>The only thing left was to test that it can actually fit inside an NES controller, and it does, sort of.\u00a0 It is maybe 2 sheets of paper too tall, which will probably be okay as long as I can make sure the wires soldered into the holes do not protrude any.\u00a0 Otherwise, I will need to remove the USB connector from the Teensy and solder the USB wires on directly.<\/p>\n<p>Next, I&#8217;ll be working on the base code I will use to create each gamepad.<\/p>\n<hr \/>\n<p>Fun Nintendo Controller Trivia:<br \/>\nThe NES and SNES controllers actually use the same exact protocol for communicating with the console.\u00a0 It is very electrically simple, and supports infinite buttons.\u00a0 The console just keeps querying each button until its done.\u00a0 The first eight buttons on the SNES are the same as the NES controller: Up, Down, Left, Right, Select, Start, B, and A.\u00a0 So if you connected the wires of an SNES controller to the NES, it would actually work.\u00a0 The NES queries 8 buttons and then stops.\u00a0 The only downside is the placement of B and A on the SNES controller don&#8217;t lend well to pressing the B and A buttons simultaneously with your thumb like you do in Super Mario Bros., etc.\u00a0 The SNES console queries the additional X, Y, L, and R buttons after the first eight.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Teensy 2.0 showed up in the mail today!\u00a0 Here it is, nice and small: It took me less than two hours to get a working gamepad in both Windows and Linux.\u00a0 I had found some code online that modified Teensy&#8217;s keyboard example to be an SNES gamepad, so a lot of the work was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-146","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":8,"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/posts\/146\/revisions\/206"}],"wp:attachment":[{"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/robertbyam.com\/ces\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}