Please Select a Port Before Upload Energia

The Arduino IDE is a groovy programming tool, it is unproblematic to use and it contains probably all resources 1 volition need to build a project, just evaluating information technology as a code editor, it is a not the perfect tool. Information technology lacks programming aiding features like IntelliSense, lawmaking suggestions, auto-complete, machine-right, and debug tools, which make the evolution of projects with a large codebase, like shooting fish in a barrel and endears developers to use code editors like Visual Studio Code and Atom. The above reason coupled with the large user base of most of these editors led to the development of plugins/extensions that enabled the use of some of them for development code for Arduino and other compatible boards.

Programming Arduino with Platform.io or Arduino extension for Visual Studio Code

For this tutorial, nosotros will take a await, how these extensions tin can be used to program Arduino. Quite a number of editors exist and unlike variation of extensions have been developed but for today's tutorial, nosotros will focus on Visual Studio Lawmaking (VScode) equally our lawmaking editor and explore information technology'due south use with the Platform.io and Arduino extensions.

At the end of today's tutorial, you will know how to develop code for the Arduino and like/compatible boards using the Arduino and Platform.io extensions on VScode.

Required components

We will use the Arduino glimmer example for demonstration of today's tutorial, thus you will merely demand the target boards.

  1. Arduino Uno (or any other lath of the family unit)
  2. NodeMCU

Any versions/variations of these boards are fine, as long equally they piece of work well when you program them using the Arduino IDE. In improver to the components mentioned to a higher place, yous will need the latest VScode setup. Follow this link to download the setup file and install it on your reckoner. Ensure y'all select the "add files to path" choice during installation. Subsequently installation, restart your reckoner to allow the installation to settle in.

With this washed, we are at present ready to utilize the extensions.

The Arduino Extension

The Arduino IDE for VScode (Visual Studio Code) was one of the earliest extension developed. There is a version of the extension adult past the community while there is another version developed by Microsoft. Any of these extensions tin exist used. For this tutorial, we volition apply the Microsoft version of the Arduino extension.

Features and Functionality

The Visual Studio Code Arduino extension retains the ease of utilise that comes with the Arduino IDE but also provides access to the superb features embedded in the visual studio code which makes coding and debugging a lot easier. Some of the features and functionalities as stated on the extension description, include:

  • intelliSense and syntax highlighting for Arduino sketches
  • Verify and upload your sketches in Visual Studio Code
  • Congenital-in board and library manager
  • Built-in example listing
  • Born serial monitor
  • Snippets for sketches
  • Automatic Arduino project scaffolding
  • Command Palette (F1) integration of oftentimes used commands (east.m. Verify, Upload…)
  • Integrated Arduino DebuggingNew

Requirements

The only requirement is to have the Arduino IDE installed from arduino.cc. The extension requires the IDE version to be version 1.6.x and up. Withal, do your best to avert the version ane.8.7 as information technology has issues that prevent library and boards installation/updates.

Installation

The Arduino extension tin exist installed from the extensions market place place or via the command line within VScode.

To install from the market place, launch the VScode editor. Yous should run into a welcome folio (shown below) -> click on the extension icon (highlighted in the image below) to access the marketplace identify.

Enter Arduino into the search bar and select the one that says developed by Microsoft. Click on the install button as shown beneath and re-launch VScode after installation completes.

Installing the Arduino Extension

Later on re-launch, the Arduino extension should be visible under your enabled extensions. With the installations done, we can now proceed to run an example with Arduino.

Example

Press the F1 function key to open the command line on VScode. One time the command line becomes visible, blazon in Arduino. It should show you a list of commands applicable to the Arduino as shown below.

With these commands you tin can install new Arduino libraries, install new boards, select target board for code upload, select a programmer and pretty much everything you lot tin practise with the Arduino IDE or fifty-fifty more. As mentioned before, we volition use the Arduino blink case as a demonstration. To kickoff with, printing F1 and select the "Arduino: Examples" option. Navigate and select the glimmer example.

Load the Blink Example

This will open the folder containing the sketch under the explorer pane in a new window. Select the .ino file if you lot wish to make whatsoever changes to the code.

Edit the code

Gear up to upload the code?

Just like when working with the Arduino IDE, press the F1 function push button and select the "Arduino: Lath configuration" option to set the target board which in our case, is the Arduino Uno.

Select Board Type

At this point, connect your Arduino board and select the "Arduino:select serial port" option afterwards pressing F1. It volition bring upwards a listing of all devices continued to the series port. Select the ane to which your Arduino is continued.

Select COM Port

Next, select the programmer past clicking on the "Arduino: Select programmer" option from the function menu. Choose any that you want.

Select Programmer

With this done, we are at present ready to upload the code. If you fabricated any change to it and you would like to verify lawmaking earlier uploading you tin can use the "Arduino: Verify" option after pressing F1. If the lawmaking is satisfactory and you lot are ready to upload, printing F1 and click the "Arduino: upload function".

If you follow all the steps carefully, the process should be easy and the code should upload successful as shown below.

Upload Successful

The Platform.io Extension

Platform.io is an open-source platform developed to facilitate the deployment of IoT solutions. Information technology allows the easy integration of IoT specific features like remote firmware update and testing. The platform supports several boards from Arduino, Espressif and their variations to TI'south MSP430, Tiva and others. It also supports frameworks like the Arduino, Energia for TI boards, and Mbed, effectively making information technology one of the most comprehensive cross-platform development tool for IoT.

Platform.io Features

Some of the outstanding features of platform.io according to their website include:

  • Cross-platform build system without external dependencies to the Os software: 550+ embedded boards, 30+ development platforms, 15+ frameworks
  • PIO Unified Debugger
  • PIO Remote
  • PIO Unit Testing
  • C/C++ Intelligent Code Completion
  • C/C++ Smart Code Linter for rapid professional person development
  • Library Manager for hundreds of popular libraries
  • Multi-projects workflow with multiple panes
  • Themes support with dark and lite colors
  • Serial Port Monitor
  • Born Terminal with PlatformIO Cadre (CLI) and CLI tool (pio, platformio)

Only similar we did with the Arduino extension for VScode, nosotros volition take a await on how theplatformio.org extension for VScode can be used for programming Arduino boards.

Installation

Just similar the Arduino extension, the platform.io extension for visual studio lawmaking can besides be installed via extension market place.

Click on the extensions/parcel manager icon, when it opens, enter "platformIO IDE" into the search bar and click on the install button equally shown below. After installation, reload VScode to let installation to take effect.

Putting it to Utilise

One time the reload is consummate, a platform.io icon will be visible on the sidebar and the platform.io toolbar volition be added to the condition bar of VScode. The toolbar contains buttons for popular commands. This makes information technology easy to quick build, upload, or perform any of the commands without much navigation.

The Platform.io Toolbar

From left to right, each icon represents;

  1. PlatformIO Domicile
  2. PlatformIO: Build
  3. PlatformIO: Upload
  4. PIO Remote
  5. PlatformIO: Clean
  6. PIO Unit of measurement Testing
  7. Run a task… (Come across "Task Runner" below)
  8. Serial Port Monitor
  9. PIO Terminal

Example

As mentioned earlier, nosotros will utilise the glimmer example hither too. To create a new project, click on the platform.io dwelling house icon and select the "New Project" button. A window similar to the 1 shown below should open up up.

Select Platform and Board blazon

This window volition allow you to select the lath, the framework and other things to set up the IDE for utilise with your target board. Since we will use the Arduino Uno, nosotros select it as the lath type and the Arduino IDE as the platform. If this were to be the NodeMCU, you will need to select the nodemcu as the board blazon and the Arduino or the ESPressif 8266 as the framework.

With the setup done, a new projection folder is created. Open the main.cpp file under the src folder to write the code for your projection.

Since we are using the blink example, you lot tin copy and paste the lawmaking below into the lawmaking editor.

/**  * Blink  *  * Turns on an LED on for one 2d,  * then off for 1 second, repeatedly.  */ #include "Arduino.h"  // Set LED_BUILTIN if it is not defined by Arduino framework // #define LED_BUILTIN 13  void setup() {   // initialize LED digital pin as an output.   pinMode(LED_BUILTIN, OUTPUT); }  void loop() {   // turn the LED on (HIGH is the voltage level)   digitalWrite(LED_BUILTIN, HIGH);    // await for a 2d   delay(1000);    // turn the LED off past making the voltage LOW   digitalWrite(LED_BUILTIN, LOW);     // await for a 2nd   filibuster(1000); }

With this done, utilise the "Build button" on the toolbar to build your code and the "Upload push button" to upload it to the target Arduino board. If the installation was properly washed, you lot should go the success remarks on the console window.

Decision

The 2 extensions we examined today are quite powerful. They can exist used to develop lawmaking for all kind of boards that are compatible with the Arduino IDE and boards that are not Arduino compatible but are supported by the plaform.io IDE (when using their extension). These extensions provide a lot of flexibility and features that make the development of projects with a large lawmaking base like shooting fish in a barrel, ensuring you don't repeat lines via code suggestions and intellisense. They too ensure yous keep all the files for a projection in a unmarried binder which makes it easy to manipulate and move things around. It might exist handy for your side by side mega project.

Experience gratuitous to accomplish out via the comment section if you accept any difficulty setting things up.

That'due south all for today's tutorial.

Till Next time.

winningoply1938.blogspot.com

Source: https://www.electronics-lab.com/project/programming-arduino-platform-io-arduino-extension-visual-studio-code-editor/

0 Response to "Please Select a Port Before Upload Energia"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel