{"id":331,"date":"2011-05-26T23:04:23","date_gmt":"2011-05-26T21:04:23","guid":{"rendered":"http:\/\/www.albertopasca.it\/whiletrue\/?p=331"},"modified":"2018-05-25T11:44:40","modified_gmt":"2018-05-25T09:44:40","slug":"arduino-edit-and-compile-with-visual-studio","status":"publish","type":"post","link":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/","title":{"rendered":"[Arduino] Edit and compile with Visual Studio"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg\" alt=\"\" \/><\/p>\n<p>I prefer to use the Visual Studio 2008 environment to write and test code for the Arduino. The following steps outline what is necessary to accomplish this.<\/p>\n<p><!--more--><\/p>\n<p>Note that this requires two files to be added that are stub\u2019s for the normal Arduino functions. The stubs provided here use defines for the Arduino Mega and create a simple console application that will map console input\/output to the Arduino serial input\/output.<\/p>\n<p>For those of you who have more time at hand, it would be nice to write a windows stub which will also allow to see \/ control the I\/O pins.<\/p>\n<p>If you need support for other boards you need to edit the\u00a0<a class=\"wikilink\" href=\"http:\/\/arduino.cc\/playground\/Code\/VisualStudioVSPDEH\">VSPDE.h<\/a>\u00a0file.<\/p>\n<p>Also the\u00a0<a class=\"wikilink\" href=\"http:\/\/arduino.cc\/playground\/Code\/VisualStudioVSPDECPP\">VSPDE.cpp<\/a>\u00a0file does not implement all the Arduino functions, so if you need more, please feel free to update the code.<\/p>\n<p>Main objective for me was to be able to edit and compile, and in a limited way run and debug code using Visual Studio. This will do just that (and nothing more)!<\/p>\n<h2>Step 1: Ensure .pde files are seen as C++ files<\/h2>\n<p>Open regedit and under \\HKEY_CLASSES_ROOT create a new key called \u201c.pde\u201d and change the default value to \u201ccppfile\u201d.<\/p>\n<pre>\r\n   [HKEY_CLASSES_ROOT\\.pde]\r\n   @=\"cppfile\"\r\n<\/pre>\n<h2>Step 2: Configure Visual Studio<\/h2>\n<ol>\n<li>Under tools \\ options \\ Projects and Solutions\\VC++ Project settings add \u2018*.pde\u2019 to \u2018C\/C++ File Extensions\u2019 and \u2018.pde\u2019 to the \u2018Extensions to Include\u2019<\/li>\n<li>Under tools\\options\\Text Editor\\File Extension add PDE and map it to the C++ editor<\/li>\n<li>Close Visual Studio to effect the changes<\/li>\n<\/ol>\n<h2>Step 3: Create a Visual Studio project<\/h2>\n<ol>\n<li>Start by creating a new (empty) sketch using the Arduino editor<\/li>\n<li>Next create a Visual C++ \u2018Empty Project\u2019 for the sketch in the same folder<\/li>\n<li>In the solution, right click and select Add, Existing item to add the .PDE file(s)<\/li>\n<li>Select the .PDE files, right click and in the file properties set the file type to \u2018C\/C++ Code\u2019<\/li>\n<li>Add the\u00a0<a class=\"wikilink\" href=\"http:\/\/arduino.cc\/playground\/Code\/VisualStudioVSPDEH\">VSPDE.h<\/a>\u00a0and\u00a0<a class=\"wikilink\" href=\"http:\/\/arduino.cc\/playground\/Code\/VisualStudioVSPDECPP\">VSPDE.cpp<\/a>\u00a0files<\/li>\n<li>Add an #include statement for the VSPDE.h file in the .pde files.<\/li>\n<li>You can now edit, compile and run the program as a console application (without I\/O support!)<\/li>\n<\/ol>\n<h2>Step 4: Configure Arduino<\/h2>\n<p>Under File\\Preferences set the \u2018Use external editor\u2019 checkmark.<br \/>\nNow you can use Visual studio to edit and when done just Alt-Tab to the Arduino application and press the upload button to compile the latest code and upload it to the board. The Arduino program will automatically monitor for file changes so you do not need to refresh anything!<\/p>\n<p>Rif: www.arduino.cc<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I prefer to use the Visual Studio 2008 environment to write and test code for the Arduino. The following steps outline what is necessary to accomplish this.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_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},"jetpack_post_was_ever_published":false},"categories":[1],"tags":[257,323,322,325,324],"class_list":["post-331","post","type-post","status-publish","format-standard","hentry","category-generic","tag-arduino","tag-compile","tag-editor","tag-ide","tag-visual-studio"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Arduino] Edit and compile with Visual Studio - while (true) {\u00a0}<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Arduino] Edit and compile with Visual Studio - while (true) {\u00a0}\" \/>\n<meta property=\"og:description\" content=\"I prefer to use the Visual Studio 2008 environment to write and test code for the Arduino. The following steps outline what is necessary to accomplish this.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/\" \/>\n<meta property=\"og:site_name\" content=\"while (true) {\u00a0}\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-26T21:04:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-25T09:44:40+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg\" \/>\n<meta name=\"author\" content=\"Alberto Pasca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lupasca\" \/>\n<meta name=\"twitter:site\" content=\"@lupasca\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alberto Pasca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/\"},\"author\":{\"name\":\"Alberto Pasca\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"headline\":\"[Arduino] Edit and compile with Visual Studio\",\"datePublished\":\"2011-05-26T21:04:23+00:00\",\"dateModified\":\"2018-05-25T09:44:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/\"},\"wordCount\":429,\"publisher\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.gorditosybonitos.com\\\/wp-content\\\/uploads\\\/2011\\\/01\\\/logo_arduino.jpg\",\"keywords\":[\"arduino\",\"compile\",\"editor\",\"ide\",\"visual studio\"],\"articleSection\":[\"generic\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/\",\"url\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/\",\"name\":\"[Arduino] Edit and compile with Visual Studio - while (true) {\u00a0}\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#primaryimage\"},\"image\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.gorditosybonitos.com\\\/wp-content\\\/uploads\\\/2011\\\/01\\\/logo_arduino.jpg\",\"datePublished\":\"2011-05-26T21:04:23+00:00\",\"dateModified\":\"2018-05-25T09:44:40+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.gorditosybonitos.com\\\/wp-content\\\/uploads\\\/2011\\\/01\\\/logo_arduino.jpg\",\"contentUrl\":\"http:\\\/\\\/www.gorditosybonitos.com\\\/wp-content\\\/uploads\\\/2011\\\/01\\\/logo_arduino.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/arduino-edit-and-compile-with-visual-studio\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Arduino] Edit and compile with Visual Studio\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\",\"url\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\",\"name\":\"while (true) {\u00a0}\",\"description\":\"notes from a developer, tutorials, how-to, ideas\",\"publisher\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\",\"name\":\"Alberto Pasca\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"caption\":\"Alberto Pasca\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\"},\"description\":\"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.\",\"sameAs\":[\"https:\\\/\\\/www.albertopasca.it\",\"albertopasca\",\"https:\\\/\\\/x.com\\\/lupasca\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Arduino] Edit and compile with Visual Studio - while (true) {\u00a0}","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/","og_locale":"en_US","og_type":"article","og_title":"[Arduino] Edit and compile with Visual Studio - while (true) {\u00a0}","og_description":"I prefer to use the Visual Studio 2008 environment to write and test code for the Arduino. The following steps outline what is necessary to accomplish this.","og_url":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/","og_site_name":"while (true) {\u00a0}","article_published_time":"2011-05-26T21:04:23+00:00","article_modified_time":"2018-05-25T09:44:40+00:00","og_image":[{"url":"http:\/\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg","type":"","width":"","height":""}],"author":"Alberto Pasca","twitter_card":"summary_large_image","twitter_creator":"@lupasca","twitter_site":"@lupasca","twitter_misc":{"Written by":"Alberto Pasca","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#article","isPartOf":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/"},"author":{"name":"Alberto Pasca","@id":"http:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"headline":"[Arduino] Edit and compile with Visual Studio","datePublished":"2011-05-26T21:04:23+00:00","dateModified":"2018-05-25T09:44:40+00:00","mainEntityOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/"},"wordCount":429,"publisher":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#primaryimage"},"thumbnailUrl":"http:\/\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg","keywords":["arduino","compile","editor","ide","visual studio"],"articleSection":["generic"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/","url":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/","name":"[Arduino] Edit and compile with Visual Studio - while (true) {\u00a0}","isPartOf":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/#website"},"primaryImageOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#primaryimage"},"image":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#primaryimage"},"thumbnailUrl":"http:\/\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg","datePublished":"2011-05-26T21:04:23+00:00","dateModified":"2018-05-25T09:44:40+00:00","breadcrumb":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#primaryimage","url":"http:\/\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg","contentUrl":"http:\/\/www.gorditosybonitos.com\/wp-content\/uploads\/2011\/01\/logo_arduino.jpg"},{"@type":"BreadcrumbList","@id":"http:\/\/www.albertopasca.it\/whiletrue\/arduino-edit-and-compile-with-visual-studio\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.albertopasca.it\/whiletrue\/"},{"@type":"ListItem","position":2,"name":"[Arduino] Edit and compile with Visual Studio"}]},{"@type":"WebSite","@id":"http:\/\/www.albertopasca.it\/whiletrue\/#website","url":"http:\/\/www.albertopasca.it\/whiletrue\/","name":"while (true) {\u00a0}","description":"notes from a developer, tutorials, how-to, ideas","publisher":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.albertopasca.it\/whiletrue\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"http:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac","name":"Alberto Pasca","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","caption":"Alberto Pasca"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g"},"description":"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.","sameAs":["https:\/\/www.albertopasca.it","albertopasca","https:\/\/x.com\/lupasca"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/comments?post=331"}],"version-history":[{"count":3,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/331\/revisions"}],"predecessor-version":[{"id":751,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/331\/revisions\/751"}],"wp:attachment":[{"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media?parent=331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/categories?post=331"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/tags?post=331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}