Skip to content

VSCode - Python

Download and Install the VSCode

In this tutorial, we will demonstrate how to download and install VSCode (Visual Studio Code) on your Windows, Mac, or Linux computer.

VSCode

VSCode is an elegant, free, and open-source code editor developed by Microsoft. It serves as a cross-platform solution, supporting numerous programming languages such as Python and C++. With features including syntax highlighting, code completion, and error detection, it empowers developers with a robust set of tools. Furthermore, its extension plugin system allows for customization and enhanced functionality, catering to diverse development requirements.

Download the Editor

[Download the VSCode] .

image.png

Installation and Open VSCode

Windows

Install VSCode on your computer.

image.png

macOS

Install VSCode on your computer.

image.png

Linux

Install VSCode on your computer.

070ee0f4c985d902b66e25775fddb0f.png

Starting up the UNIHIKER

Connect the UNIHIKER

Connect the UNIHIKER to your computer using the Type-C to USB cable. Once connected and powered on, the UNIHIKER logo will appear on the screen.

Note

  1. Please ensure that you plug the USB cable directly into the computer's USB port without using an extension cord or dock. If you experience any issues with the connection, refer to the FAQ for a solution.
  2. When the UNIHIKER is connected to your PC via USB, the IP address is fixed at 10.1.2.3. You can find the IP address in the "Home" menu of the UNIHIKER.

Run a simple example with VSCode

The VSCode software supports programming the UNIHIKER through Python code, you can create a simple example as follows.

(1) Launch the VSCode software, and you will see a screen similar to this.

image.png

(2) Install the "Python" extension from the VSCode Extensions marketplace.

image.png

(3) Search for the "remote" extension and install "Remote - SSH".
SSH (Secure Shell) is a network protocol that enables secure remote access and data transfer between computers over unsecured networks. It establishes an encrypted channel to ensure the security and integrity of the data transmitted.
The UNIHIKER has SSH service enabled by default, allowing you to use SSH tools such as PuTTY, MobaXterm, or Remote-SSH in VSCode to connect to it from another computer.

image.png

(4) Once the installation is complete, you will find the Remote Explorer in VSCode. To add a new connection, enter the SSH account as "root" and the password as "dfrobot". When connected via USB, the IP address is fixed as "10.1.2.3". Therefore, enter "root@10.1.2.3" and select "Linux". Enter the password when prompted.

image.png

Input 'root@10.1.2.3' as host.

image.png

Select 'Linux' from the newly appeared pop-up window.

image.png

Input the password 'dfrobot' and press Enter.

image.png

Note: If the connection fails, please retry multiple times.
After successful connection, the status bar will display as follows.

image.png

Note: If you encounter any connection issues, please ensure that the USB cable is correctly plugged in.

(5) Once connected, you can select the UNIHIKER directory to open files and write programs for execution later.

image.png

Input the password 'dfrobot' and press Enter.

image.png

After completing the previous step, you will see a screen like this. The first part corresponds to the sidebar, which serves as the file directory area of the board. The second part is the Panel Bar, which includes sections for problems, output, terminal, debug console, and ports.

image.png

(6) Then, we can click "+" option here to create a new file named "Hi_UNIHIKER.py" .

image.png

(7) After creating the file, we can double-click on the "Hi_UNIHIKER.py" file to program it in the code editing area of the program, as shown below.

image.png

(8οΌ‰Please insert this code into the code editing area of the file "Hi_UNIHIKER.py". Here's a code snippet that will display "HI UNIHIKER" on the screen.

from unihiker import GUI
import time

gui = GUI()
#unihiker text
gui.draw_text(text="HI UNIHIKER",origin="center",x=120,y=160,color="#0066CC")

while True:
    time.sleep(1)

(9οΌ‰Run the program on the UNIHIKER. Right-click on the 'Hi_UNIHIKER.py' file, choose 'Open in Integrated Terminal', then input 'python Hi_UNIHIKER.py' and press Enter.

image.png

After running the code, the result will demonstrate on the screen.

image.png


Congratulations, you have successfully implemented programming control for the UNIHIKER. Now, you can explore exciting projects or understanding deeper of UNIHIKER.The possibilities are endless with UNIHIKER. Have fun exploring and learning!

1. Discover more programming exercises: Examples
2. Explore Python libraries related to UNIHIKER: Reference
3. Gain insights into the built-in hardware of UNIHIKER: Hardware