{"id":445,"date":"2015-02-09T21:43:54","date_gmt":"2015-02-09T20:43:54","guid":{"rendered":"http:\/\/axotron.se\/blog\/?p=445"},"modified":"2015-08-01T18:17:54","modified_gmt":"2015-08-01T17:17:54","slug":"getting-started-with-teensy","status":"publish","type":"post","link":"https:\/\/axotron.se\/blog\/getting-started-with-teensy\/","title":{"rendered":"Getting Started with Teensy"},"content":{"rendered":"<p>I just bought a couple of <a href=\"https:\/\/www.pjrc.com\/teensy\/index.html\" target=\"_blank\">Teensy 3.1<\/a> boards to play with. The Teensy is a pretty small processor board that looks to be quite capable. It is smaller than the Arduino Nano boards I have been using for various other projects and still it has more I\/Os, is cheaper and has a much more powerful processor, an MK20DX256, which is a 32-bit ARM Cortex-M4 from Freescale running at 72 MHz with 256 kB flash and 64 kB RAM.<\/p>\n<figure id=\"attachment_446\" aria-describedby=\"caption-attachment-446\" style=\"width: 600px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2015\/02\/teensy.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-446\" src=\"http:\/\/axotron.se\/blog\/wp-content\/uploads\/2015\/02\/teensy.jpg\" alt=\"Teensy 3.1\" width=\"600\" height=\"319\" srcset=\"https:\/\/axotron.se\/blog\/wp-content\/uploads\/2015\/02\/teensy.jpg 600w, https:\/\/axotron.se\/blog\/wp-content\/uploads\/2015\/02\/teensy-300x160.jpg 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-446\" class=\"wp-caption-text\">Teensy 3.1<\/figcaption><\/figure>\n<p>The downside is perhaps that it is a proprietary design and while the schematics is available, the bootloader running on it is not, so unlike with the Arduino Nano, it is not possible to start out with a Teensy for prototypes and then move to a custom layout while still being able to use the same bootloader.<\/p>\n<p>It is possible to develop programs for the Teensy using both an <a href=\"https:\/\/www.pjrc.com\/teensy\/td_download.html\" target=\"_blank\">adapted version <\/a>of the Arduino environment as well as using Eclipse. There are quite a few libraries available, including NeoPixel, OneWire, Xbee, capacitive sensing, IR remote controls, LCD displays, PS2 keyboard input, CAN, stepper motor control etc.<\/p>\n<p>First you need to install the normal Arduino environment, and then the above mentioned adaptations. When you subsequently run the Arduino environment, a number of Teensy board versions are now available as target boards. Also several example programs are available in the menu\u00a0 File -&gt; Examples -&gt; Teensy.<\/p>\n<p>To get started I took the very simple LED-blinking program Blinky and added some parameters to modify the blinking to make it easy to see if I was successful in uploading the new program. Here is the code I came up with:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/* LED Blink, Teensy Tutorial #1\r\n\u00a0\u00a0 http:\/\/www.pjrc.com\/teensy\/tutorial.html\r\n\u00a0\r\n\u00a0\u00a0 This example code is in the public domain.\r\n\u00a0\u00a0 Modified by Per Magnusson\r\n*\/\r\n\r\n\/\/ Teensy 3.1 has the LED on pin 13\r\nconst int ledPin = 13;\r\nconst int ontime = 50;\u00a0\u00a0\u00a0\u00a0 \/\/ LED on time in ms\r\nconst int offtime = 50;\u00a0\u00a0\u00a0 \/\/ LED off time in ms\r\nconst int pausetime = 1000; \/\/ Pause time between bursts\r\nconst int blinks = 10;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Number of blinks per burst\r\n\r\n\/\/ the setup() function runs once, when the sketch starts\r\n\r\nvoid setup() {\r\n\u00a0 \/\/ initialize the digital pin as an output.\r\n\u00a0 pinMode(ledPin, OUTPUT);\r\n}\r\n\r\n\/\/ the loop() function runs over and over again,\r\n\/\/ as long as the board has power\r\n\r\nvoid loop() {\r\n\u00a0 for(int i=1; i&lt;=blinks; i++) \r\n\u00a0 {\r\n\u00a0\u00a0\u00a0 digitalWrite(ledPin, HIGH);\u00a0\u00a0\u00a0\u00a0 \/\/ turn the LED on\r\n\u00a0\u00a0\u00a0 delay(ontime);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ wait\r\n\u00a0\u00a0\u00a0 digitalWrite(ledPin, LOW);\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ turn the LED off\r\n\u00a0\u00a0\u00a0 delay(offtime);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ wait\r\n\u00a0 }\r\n\u00a0 delay(pausetime-offtime);\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ wait for the next burst of blinks\r\n}\r\n<\/pre>\n<p class=\"size-full wp-image-446\">Uploading of the sketch to the device turned out to be a bit messy. It seems to be necessary to press the button on the Teensy prior to uploading. Pressing the Auto button in a small window that appears on the screen might also help. Just uploading without doing anything special results in a timeout and the previous sketch being stopped.<\/p>\n<p class=\"size-full wp-image-446\">Anyway, so far so good. Getting to the equivalent of Hello World turned out to be almost as easy as with an Arduino.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just bought a couple of Teensy 3.1 boards to play with. The Teensy is a pretty small processor board that looks to be quite capable. It is smaller than the Arduino Nano boards I have been using for various other projects and still it has more I\/Os, is cheaper and has a much more &hellip; <a href=\"https:\/\/axotron.se\/blog\/getting-started-with-teensy\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Getting Started with Teensy<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,2],"tags":[],"class_list":["post-445","post","type-post","status-publish","format-standard","hentry","category-arduino","category-electronics"],"_links":{"self":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/comments?post=445"}],"version-history":[{"count":3,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions"}],"predecessor-version":[{"id":636,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/445\/revisions\/636"}],"wp:attachment":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/media?parent=445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/categories?post=445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/tags?post=445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}