2. General information

Visual Studio Code is a source code editor. It supports various programming languages and can be combined with compilers to work as a package integrated development environment IDE.

VS Code has IntelliSense which allows word based completions. This you can write code syntax without typos.

You also get access to various extensions. These enhance the working of VS Code and also adds new features as per requirements.

../../_images/vs_code_logo1.png

Fig. 2.9 VS Code by Microsoft

2.1. Interface

The UI is divided into five areas (ref: VS Code):

  • Editor - The main area to edit your files. You can open as many editors as you like side by side vertically and horizontally.

  • Activity Bar - Located on the far left-hand side, this lets you switch between views and gives you additional context-specific indicators, like the number of outgoing changes when Git is enabled.

  • Side Bar - Contains different views like the Explorer to assist you while working on your project.

  • Editor Groups - You can open multiple files and can split the screen to work with two or more files simultaneously.

  • Panels - You can display different panels below the editor region for output or debug information, errors and warnings, or an integrated terminal. Panel can also be moved to the right for more vertical space.

  • Status Bar - Information about the opened project and the files you edit.

../../_images/vs_code_ui_desc.png

Fig. 2.10 VS Code UI (ref: VS Code)

Activity Bar: This includes the followings commands to manage open project: Explorer, Search, Source Control, Run & Debug and Extensions. You can switch between these to handle the project as per requirements.

Side Bar: In this area, you can create, delete and modify files of your project. You can also drag & drop files to organize content.

Note

When creating new files, PLEASE add an extension to the file. If no extension is provided, the file also has no extension!

Status Bar: It is divided in mainly two parts.
  • The left part consists of Project related stuff. Here you see master which is the working branch of the project. When you change the branch, it automatically sets it to default upload branch. The refresh icon synchronizes the content between server and local stored code. The icons near that shows information about the tips and errors in all opened files of the project.

  • The right part of the status bar shows properties related to the editor and user selected settings which apply to editor window.

Panels: The panels include Problems, Output, Debug console and Terminal. These can be opened from top Menu bar under View.

Note

The garbage can icon is used to kill the current Terminal session. If you kill the last terminal session, the Terminal tab will close automatically.

2.2. Command Palette

VS Code allows direct execution of commands for extensions. This can be done using Command Palette. Command Palette can be accessed from View -> Command Palette or using key combination CTRL + Shift + P.

To execute a command for an extension, always check for angle bracket symbol ( > ). Following the symbol, you can type the name of the extension and then you will see the different options / commands available.

../../_images/vs_code_command_palette.png

Fig. 2.11 VS Code Command Palette (ref: VS Code)

2.3. Saving Settings

When you modify settings, you will usually see 2 options, User Settings & Workspace Settings.

In user settings, the settings are saved for the user of the editor. These settings will be default for all projects opened afterwards.

In workspace settings, the settings are saved for only that specific instance of project. A new file gets created in the same project folder which can be shared with others so that everyone has the same settings while working on the project. For example, using tabs instead of spaces for indentation of code.

3. Gitlab Extension

Warning

Before starting, please confirm you have access to GitLab server of University. You can check that by logging on the following website using your fh-kennung nummer (AB1234S) and passwort: https://git.fh-aachen.de/

Todo

Please install the following softwares:

Follow the steps below to setup GitLab Account with VS Code.

From the Top Right corner, click on your profile image then Preferences. You will be redirected to new page.

../../_images/gitlab_integrate_1.png

Fig. 3.7 Step 1

On this page, select Access Token from the left menu. On the new page, enter a name for token, for example: vscode_laptop. You can leave the Expiration date empty. select all checkboxes under Select scopes. Once done, click Create personal access token.

../../_images/gitlab_integrate_2.png

Fig. 3.8 Step 2

When done, you will receive a Personal Access Token. Copy and save that for future use.

../../_images/gitlab_integrate_3.png

Fig. 3.9 Step 3

Inside VS Code, install the extension for GitLab ( https://marketplace.visualstudio.com/items?itemName=GitLab.gitlab-workflow ). Head to the extension and click on Add Account.

../../_images/gitlab_integrate_4.png

Fig. 3.10 Step 4

On top, you will see a bar requesting for a URL. Use https://git.fh-aachen.de/. Then it will ask for access token. Enter the token created from GitLab.

../../_images/gitlab_integrate_5.png

Fig. 3.11 Step 5

When successful, you will see a confirmation on bottom right corner. If not already done, Open terminal inside VS Code from Terminal -> New Terminal.

For windows users -> Enter git config --global core.editor “notepad” in it.

Enter git config --global --edit in it. A file will open in text editor. In name, enter your full name and in email, enter your fh-email id example firstname.lastname@alumni.fh-aachen.de

Now you can create / clone new repositories.

Warning

When cloning a repository, please use https:// URL. The git@git is used when setup done using SSH.

../../_images/gitlab_integrate_6.png

Fig. 3.12 Step 6

After your repository is setup successfully, you can find these options in Source Control option from left menu in VS Code.

../../_images/gitlab_integrate_7.png

Fig. 3.13 Step 7

4. Arduino Extension

Todo

Download and install the Arduino IDE to program your Arduino Uno.

Download Link: https://downloads.arduino.cc/arduino-1.8.19-windows.zip

Version: 1.8.X

Note

The Arduino extension for VS Code will automatically detect installed Arduino IDE. If in case it doesn’t happen, follow the steps below:

  • Open Extensions from Activity Bar. Search Arduino extension.

  • Click on small gear ⚙ (manage menu) next to it. It will open a new menu.

  • Click on Extension Settings. New tab will open.

  • Scroll down and find Arduino Path

  • Enter the complete installation address of your Arduino IDE. C:Program Files...

To use the extension, follow the steps below:
  • Open VS Code. Click on Open Folder from the startup interface. Open the folder Documents -> Arduino. If the folder is not found inside Documents, create a new one named Arduino. Open the Arduino folder.

  • Inside Arduino folder, click on New Folder from top bar and name the folder. PLEASE DO NOT INCLUDE SPACES IN NAME. USE UNDERSCORES ( _ ). Example, my_first_code

  • Open the new created folder. Once inside the new create folder and click on Select Folder from bottom.

  • VS Code will open with the selected folder.

  • Open Command Palette -> Arduino Initialize. A pop-up will ask for file name.

  • Enter the file name. PREFER USING SAME NAME AS FOLDER NAME. Press enter once done.

  • Select the required board. Enter UNO AVR board from the selection list.

  • Once done, you will find a project file with extension .ino and a folder .vscode in your Side Bar.

The following commands have to be used after initial setup:
  • Board Config: To change the development board.

  • Select Serial Port: To change the serial port of connected device.

  • Verify: To compile the code and check for syntax errors. This only compiles the code, does not upload it.

  • Upload: To build the code and upload it to connected board.

  • Library Manager: Allows management and download of external libraries.

  • Open Serial Monitor: To open serial monitor to see device logs and user based serial print statements.

Details about rest commands can be found here ( https://github.com/microsoft/vscode-arduino#commands )