{"id":681,"date":"2012-01-10T21:28:59","date_gmt":"2012-01-10T21:28:59","guid":{"rendered":"http:\/\/41j.com\/blog\/?p=681"},"modified":"2012-01-17T11:44:50","modified_gmt":"2012-01-17T11:44:50","slug":"arduino-uno-getting-started","status":"publish","type":"post","link":"https:\/\/41j.com\/blog\/2012\/01\/arduino-uno-getting-started\/","title":{"rendered":"Arduino Uno &#8211; Getting Started"},"content":{"rendered":"<p>I received my <a href=\"http:\/\/uk.farnell.com\/arduino\/a000046\/board-arduino-uno\/dp\/1848687\">Arduino Uno<\/a> from <a href=\"http:\/\/uk.farnell.com\/arduino\/\">Farnell<\/a> today. One of the nice things about the Arduino is that for a piece of hobbiest electronics, it&#8217;s rather attractively packaged!<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_wrapped.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_wrapped.jpg\" alt=\"\" title=\"arduino_wrapped\" width=\"600\" height=\"803\" class=\"aligncenter size-full wp-image-682\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_wrapped.jpg 600w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_wrapped-224x300.jpg 224w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_box.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_box.jpg\" alt=\"\" title=\"arduino_box\" width=\"600\" height=\"803\" class=\"aligncenter size-full wp-image-683\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_box.jpg 600w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_box-224x300.jpg 224w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_unboxed.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_unboxed.jpg\" alt=\"\" title=\"arduino_unboxed\" width=\"800\" height=\"598\" class=\"aligncenter size-full wp-image-684\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_unboxed.jpg 800w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduino_unboxed-300x224.jpg 300w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>To do anything useful with the Arduino you&#8217;ll need an &#8220;A to B type USB cable&#8221;. You&#8217;ve almost certainly got one already, they commonly come with printers and I always seem to find them around my flat hiding behind furniture.<\/p>\n<p>Download the Arduino environment <a href=\"http:\/\/arduino.cc\/en\/Main\/Software\">here<\/a>. The resulting zip file should be extracted automatically, copy &#8220;Arduino&#8221; to &#8220;Applications&#8221;.<\/p>\n<p>Plug in your Arduino. You should see the following dialog pop up:<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduinoinf.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduinoinf.png\" alt=\"\" title=\"arduinoinf\" width=\"461\" height=\"184\" class=\"aligncenter size-full wp-image-685\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduinoinf.png 461w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/arduinoinf-300x119.png 300w\" sizes=\"auto, (max-width: 461px) 100vw, 461px\" \/><\/a><\/p>\n<p>Click &#8220;Network Preferences&#8221;, when the config dialog pops up just click apply.<\/p>\n<p>Load the Arduino software!<\/p>\n<p>In the Arduino software select File->Examples->1.Basics->Blink<\/p>\n<p>Select the correct serial port. Tools->Serial Port->Something. Where something should be \/dev\/tty.usbmodemXXX if there&#8217;s more than one, some trial and error maybe involved.<\/p>\n<p>Click the upload button (highlighted in yellow below):<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardup.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardup.png\" alt=\"\" title=\"ardup\" width=\"500\" height=\"600\" class=\"aligncenter size-full wp-image-686\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardup.png 500w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardup-250x300.png 250w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>You should then see one of the lights on the board start flashing away (again highlighted):<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardlight.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardlight.jpg\" alt=\"\" title=\"ardlight\" width=\"600\" height=\"803\" class=\"aligncenter size-full wp-image-687\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardlight.jpg 600w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardlight-224x300.jpg 224w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>We can now start hacking away at the code. For example we can make the light blink out an SOS signal! The code is basically standard C. The Arduino IDE does some funky preprocessing which lets you get away without including a bunch of header files, but as I understand it it&#8217;s really just C underneath.<\/p>\n<p>Here&#8217;s my SOS code:<\/p>\n<p><a href=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardsos.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardsos.png\" alt=\"\" title=\"ardsos\" width=\"433\" height=\"774\" class=\"aligncenter size-full wp-image-688\" srcset=\"https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardsos.png 433w, https:\/\/41j.com\/blog\/wp-content\/uploads\/2012\/01\/ardsos-167x300.png 167w\" sizes=\"auto, (max-width: 433px) 100vw, 433px\" \/><\/a><\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\r\n\/*\r\n  SOS\r\n *\/\r\n\r\nvoid setup() {                \r\n  \/\/ initialize the digital pin as an output.\r\n  \/\/ Pin 13 has an LED connected on most Arduino boards:\r\n  pinMode(13, OUTPUT);     \r\n}\r\n\r\nvoid loop() {\r\n  \/\/ SOS\r\n  short_pulse();\r\n  short_pulse();\r\n  short_pulse();\r\n  long_pulse();\r\n  long_pulse();\r\n  long_pulse();\r\n  short_pulse();\r\n  short_pulse();\r\n  short_pulse();\r\n  delay(5000);              \/\/ wait for a while\r\n}\r\n\r\nvoid short_pulse() {\r\n  digitalWrite(13, HIGH);  \/\/ set the LED on\r\n  delay(200);              \/\/ wait for a second\r\n  digitalWrite(13, LOW);   \/\/ set the LED off\r\n  delay(500);              \/\/ wait a while\r\n}\r\n\r\nint long_pulse() {\r\n  digitalWrite(13, HIGH);   \/\/ set the LED on\r\n  delay(1000);              \/\/ wait for a second\r\n  digitalWrite(13, LOW);    \/\/ set the LED off\r\n  delay(500);               \/\/ wait a while\r\n}\r\n<\/pre>\n<p>Hit Upload again and you should see the light blinking an SOS at you! Embedded programming shouldn&#8217;t be this easy it isn&#8217;t right!! \ud83d\ude42<\/p>\n<p>If you&#8217;re in the UK you can get an Arduino Uno from Farnell <a href=\"http:\/\/uk.farnell.com\/arduino\/a000046\/board-arduino-uno\/dp\/1848687?ICID=i-9ec8-00001000\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I received my Arduino Uno from Farnell today. One of the nice things about the Arduino is that for a piece of hobbiest electronics, it&#8217;s rather attractively packaged! To do anything useful with the Arduino you&#8217;ll need an &#8220;A to B type USB cable&#8221;. You&#8217;ve almost certainly got one already, they commonly come with printers [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-681","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1RRoU-aZ","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/681","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/comments?post=681"}],"version-history":[{"count":9,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/681\/revisions"}],"predecessor-version":[{"id":711,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/posts\/681\/revisions\/711"}],"wp:attachment":[{"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/media?parent=681"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/categories?post=681"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/41j.com\/blog\/wp-json\/wp\/v2\/tags?post=681"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}